I'm performing some source processing between C preprocessing and C compilation. At the moment I:
gcc -E file.c > preprocessed_file.c.- Do more stuff to
preprocessed_file.c. - Continue the compilation with
preprocessed_file.c.
If you attempt to compile preprocessed_file.c as you would if it was normal C (step 3) you get lots of the following:
/usr/include/stdio.h:257: error: redefinition of parameter ‘restrict’ /usr/include/stdio.h:257: error: previous definition of ‘restrict’ was here /usr/include/stdio.h:258: error: conflicting types for ‘restrict’ /usr/include/stdio.h:258: error: previous definition of ‘restrict’ was here /usr/include/stdio.h:260: error: conflicting types for ‘restrict’ [...] And that's just using #include <stdio.h> in file.c. Fortunately there's an option to tell GCC it's acting on C code that has already been preprocessed by specifying the language that is being compiled as c-cpp-output (see -x on this page). But it doesn't work. I just get this:
$ gcc -x c-cpp-output -std=c99 bar.c i686-apple-darwin9-gcc-4.0.1: language c-cpp-output not recognized i686-apple-darwin9-gcc-4.0.1: language c-cpp-output not recognized ld warning: in bar.c, file is not of required architecture Undefined symbols: "_main", referenced from: start in crt1.10.5.o ld: symbol(s) not found collect2: ld returned 1 exit status And exactly the same response with a newer version of GCC:
$ gcc-mp-4.4 -x c-cpp-output -std=c99 bar.c [same error stuff comes here]