www.delorie.com/djgpp/v2faq/faq054.html | search |
| Previous | Next | Up | Top |
Q: I type GCC PROG.C to compile a C program which I already remember to pass compilation without a single warning, and suddenly it gives all kinds of strange error messages and unresolved externals.
In the examples above, PROG.C is taken as a C++ program, not a C one, and PROG.CC is passed to the linker as if it were an object file. You can see what GCC does by adding the -v switch to the GCC command line; if you see that it's invoking cc1plus.exe (the C++ compiler) instead of cc1.exe (the C compiler), or calling ld.exe (the linker) on a source file, then you'd know this is your problem. If you have problems keeping up with the verbose GCC output caused by -v, see how to capture GCC output, earlier in this FAQ.
You can override the default rules gcc uses to decide how each input file should be treated, using the -x LANGUAGE switch. For instance, the command
gcc -x c++ prog.ccompiles prog.c as C++ source. See the "Overall Options" section of the "The GNU C Compiler Manual", for more info on -x options.
webmaster donations bookstore | delorie software privacy |
Copyright ⌐ 1998 by Eli Zaretskii | Updated Sep 1998 |
You can help support this site by visiting the advertisers that sponsor it! (only once each, though)