c preprocessor - How to partially preprocess a C file with specific working directory -


i expand include directives of c file of working directory only; not system directory.

i tried following:

gcc -e -nostdinc -i./ input.c 

but stops preprocessing when fails find included system headers in input.c. copy include directive when can't find , keep preprocessing file.

if input.c file contains system headers, it's normal preprocessor crashes when cannot find them.

you first use grep -v remove #include of system headers in code, achieving (list non-exhaustive):

grep -ve "(stdio|stdlib)\.h" code.c > code_.c 

you instance:

#define exitcode 0 int main(){   int = eof;   printf("hello\n");   return exitcode; } 

then pre-process:

s:\c>gcc -e code_.c # 1 "code_.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "code_.c"  int main(){   int = eof;   printf("hello\n");   return 0; } 

note pre-processor doesn't care functions or macros not defined. code preprocessed (and macros expanded), not system ones.

you have process included files of course. means layer of tools create temp source files , work there.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -