简体   繁体   中英

How do I turn off the gcc preprocessor on linux?

I have googled turning off the gcc preprocessor on linux for a good while now (using that exact phrase) and everything has been irrelevant. For example I want to turn off everything except the preprocessor (the opposite of what I want) or pressurising warnings. Does anyone know of a way to disable the preprocessor? I found one that Facebook developed and claimed is faster, and I would like to test it out.

Name your file program.i instead of program.c and it will be treated as already pre-processed by GCC/Clang and sent directly to the compiler.

Example:

$ cat t.i
int printf(const char *f, ...);

int main(){
  printf("hello world\n");
}
$ gcc t.i && ./a.out 
hello world

I tested what lornix said in a comment, and it works:

Name the other/newer preprocessor "cpp" and put it in your path, and rename the original cpp to cpp-other or cpp-orig. It'll work great considering you are attempting to replace cpp anyways.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM