nhan@leo.UUCP (Hugh Nhan) (10/24/89)
Hi netters: Could anyone lights me up with this simple problem. While i was VIing a file, named foo.c, i tried to do: :!cc % i got the following error: "ld crt0.o fatal: Can't open file foo.c for input" but if i did: :!cc foo.c then everything was fine. It seems to me that the shell substituted '%' for the current file name correctly, but the search path was somewhere else!!! I only got such problem on AT&T machine SYSV 2.1.2. Thanx for your helps in advance.
robert@shangri-la.gatech.edu (Robert Viduya) (10/24/89)
> > Could anyone lights me up with this simple problem. > While i was VIing a file, named foo.c, i tried to do: > :!cc % > i got the following error: > "ld crt0.o fatal: Can't open file foo.c for input" > but if i did: > :!cc foo.c > then everything was fine. It seems to me that the shell substituted '%' for > the current file name correctly, but the search path was somewhere else!!! > Some corrections: it's vi that substitutes "%" with the current file name, not the shell and there's nothing wrong with the search path. For some internal reason, when vi substitutes the "%", it puts the current file name in with all the characters having their high-bit set. You can't tell the difference on your screen since that high-bit is used as a parity bit on serial lines and gets filtered out, but when vi calls the shell to execute the command those bits are in there and as a result, the compiler can't find the file. System V allows you to have full 8-bit character file names and "foo.c" with the high-bit clear is an entirely different name from "foo.c" with the high-bit set. That's also the reason why ld generated the error message and not cc or cpp or ccom. The compiler looks for a ".c" with the high-bit clear to determine if the file is C source (as well as other "." extensions for other file types); anything it doesn't recognize gets passed to ld. The solution to the problem is to fix vi. If you don't have source and can't do that, the next best solution is to fix your shell to filter out high-bits (which prevents you from taking advantage of that feature). If you've got the Korn shell, there is a compile time flag as well as a few comments in the installation documentation that tell you why and how to use it. robert -- Robert Viduya robert@shangri-la.gatech.edu Office of Computing Services Georgia Institute of Technology (404) 894-6296 Atlanta, Georgia 30332-0275
gast@lanai.cs.ucla.edu (David Gast) (10/27/89)
In article <2738@hydra.gatech.EDU> robert@shangri-la.gatech.edu (Robert Viduya) writes: >> >> Could anyone lights me up with this simple problem. >> While i was VIing a file, named foo.c, i tried to do: >> :!cc % >> i got the following error: >> "ld crt0.o fatal: Can't open file foo.c for input" >For some internal >reason, when vi substitutes the "%", it puts the current file name in with all >the characters having their high-bit set. You can't tell the difference on your >screen since that high-bit is used as a parity bit on serial lines and gets >filtered out, but when vi calls the shell to execute the command those bits >are in there and as a result, the compiler can't find the file. System V allows >you to have full 8-bit character file names and "foo.c" with the high-bit clear >is an entirely different name from "foo.c" with the high-bit set. > >The solution to the problem is to fix vi. If you don't have source and can't >do that, the next best solution is to fix your shell to filter out high-bits >(which prevents you from taking advantage of that feature). If you don't have source to vi or the shell or you just don't want to start hacking: 1) Use tr to clear the 8th bit. (I presume that Sys V can do this; I don't know for sure.) 2) Write a trival C program to clear the eighth bit. 3) Write a trivial shell program--call it ccc. Invoke it as :!ccc %. ccc passes its arguments through tr (from above) and then calls cc with the arguments you really want. Note: You don't filter the file through tr, you filter the arguments. David Gast gast@cs.ucla.edu {uunet,ucbvax,rutgers}!{ucla-cs,cs.ucla.edu}!gast