splin@roma.berkeley.edu (Steven Lin) (03/22/91)
I probably missed the discussion on this, but I tried to compile the
"hello world" program using
gcc hello.c
where hello.c is:
#include <stdio.h>
main()
{
printf("hello world\n");
}
and got the error listed in the subject.
The error doesn't occur if I type in the program using
copy con hello.c
but it does occur if I use a word processor (vi and Wordstar) to create
hello.c. Evidently, the word processor is adding some extra characters
to the end of the file before writing to disk and gcc is choking on this.
Assuming that I can't prevent the word processor from adding these
characters, how does one eliminate this error? If this is a bug, is there
a fix for it available?
valley@uchicago (Doug Dougherty) (03/22/91)
splin@roma.berkeley.edu (Steven Lin) writes: >and got the error listed in the subject. >The error doesn't occur if I type in the program using > copy con hello.c >but it does occur if I use a word processor (vi and Wordstar) to create >hello.c. Evidently, the word processor is adding some extra characters >to the end of the file before writing to disk and gcc is choking on this. This is the ^Z problem, right? Funny, my version of vi doesn't put no steenkin' ^Z's at the end of my files. Either find an editor that doesn't put out ^Z's, or find a utility to fix ^Z'd files. I have one if you don't find one elsewhere.
mcastle@mcs213e.cs.umr.edu (Mike Castle {Nexus}) (03/23/91)
In article <valley.669642824@gsbsun> valley@uchicago (Doug Dougherty) writes: >splin@roma.berkeley.edu (Steven Lin) writes: >>The error doesn't occur if I type in the program using >> copy con hello.c >>but it does occur if I use a word processor (vi and Wordstar) to create >>hello.c. Evidently, the word processor is adding some extra characters >>to the end of the file before writing to disk and gcc is choking on this. > >This is the ^Z problem, right? Funny, my version of vi doesn't >put no steenkin' ^Z's at the end of my files. Try this: ren hello.c ohello.c type ohello.c > hello.c del ohello.c Voila! -- Mike Castle (Nexus) S087891@UMRVMA.UMR.EDU (preferred) | XEDIT: Emacs mcastle@mcs213k.cs.umr.edu (unix mail-YEACH!)| on a REAL Life is like a clock: You can work constantly, and be right | operating all the time, or not work at all, and be right twice a day. | system. :->
andy@mks.com (Andy Toy) (03/23/91)
Newer versions of Wordstar (I can't remember which versions) allow you to turn off the infamous `pad to the end of the block with ^Z' feature (holdover from CP/M). I don't know of any versions of vi that leave ^Z at the end of the file. I know that our version of vi does not write ^Z at EOF. If yours does then see if there is an option to turn off the ^Z writing (try typing `:set all' to see all the options). -- Andy Toy, Department of Computing Services, Extension 31, second floor annex
roy%cybrspc@cs.umn.edu (Roy M. Silvernail) (03/25/91)
valley@uchicago (Doug Dougherty) writes: > splin@roma.berkeley.edu (Steven Lin) writes: > > > >The error doesn't occur if I type in the program using > > copy con hello.c > >but it does occur if I use a word processor (vi and Wordstar) to create [...] > > This is the ^Z problem, right? Funny, my version of vi doesn't > put no steenkin' ^Z's at the end of my files. > > Either find an editor that doesn't put out ^Z's, or find a utility > to fix ^Z'd files. I have one if you don't find one elsewhere. I think your solution has its phase inverted. He needs a file _with_ a ^Z appended. Since that's the only way to terminate a 'copy con foo', there must be a ^Z at the end of the file that worked. -- Roy M. Silvernail -- roy%cybrspc@cs.umn.edu - OR- cybrspc!roy@cs.umn.edu perl -e '$x = 1/20; print "Just my \$$x! (adjusted for inflation)\n"' [space reserved for clever quote]{mail your submissions}
valley@uchicago (Doug Dougherty) (03/26/91)
roy%cybrspc@cs.umn.edu (Roy M. Silvernail) writes: >valley@uchicago (me) writes: >[...] >> >> This is the ^Z problem, right? Funny, my version of vi doesn't >> put no steenkin' ^Z's at the end of my files. >> >> Either find an editor that doesn't put out ^Z's, or find a utility >> to fix ^Z'd files. I have one if you don't find one elsewhere. >I think your solution has its phase inverted. He needs a file _with_ a >^Z appended. Since that's the only way to terminate a 'copy con foo', >there must be a ^Z at the end of the file that worked. I doubt it. I just did copy con foo, typed "this is a test" (14 chars), then ^Z and enter, and got a 16 char file (14 + CR/LF). Inspection with DEBUG showed no steekin' ^Z. Besides, Wordstar, a known CP/M program ported to DOS is likely to be emitting ^Z's, given its heritage. Finally, it was noted quite a while ago that djgcc choked on ^Z files, and while I have not observed it myself, I was merely parrotting (sp?) that line. (Hope this helps, Roy...)
dj@bragi.ctron.com (DJ Delorie) (03/26/91)
In article <F0BcZ1w163w@cybrspc> roy%cybrspc@cs.umn.edu (Roy M. Silvernail) writes: >I think your solution has its phase inverted. He needs a file _with_ a >^Z appended. Since that's the only way to terminate a 'copy con foo', >there must be a ^Z at the end of the file that worked. No, I don't. The ^Z wasn't being parsed out as being part of a "text" file (bug) and being passed to cpp, which couldn't handle it. The new version (soon) is much better at handling text files. To remove the ^Z via symdeb: C> symdeb file.txt <gunk> -r cx cx-1 -w <more gunk> -q For debug, you'll have to do the "r cx cx-1" by hand via "r", "r cx", and exter the right value. DJ
mishima@hpujsda.HP.COM (Ryuji Mishima) (03/29/91)
>To remove the ^Z via symdeb: > >C> symdeb file.txt ><gunk> >-r cx cx-1 >-w ><more gunk> >-q > >For debug, you'll have to do the "r cx cx-1" by hand via "r", "r cx", and >exter the right value. > >DJ Simply, use DOS copy command. copy file.txt /a file.c /b BTW, does anyone port the program from UNIX using this GCC? mishima@hpujisa.yhp.hp.com