How do I get the preprocessed output of a header file?

I have a header file where I used:

#if defined(LINUX) || defined(ANDROID)
 pthread_t gpthread;
 #endif

      

Now I would like to get only the content of the header file after passing -DLINUX in compilation. Is there a way to get it? If I use:

#arm-linux-androideabi-g++ -E main.c > temp

      

then the conclusion confuses me a little.

+3


source to share


3 answers


You can simply ask the compiler to do preprocessing in the header file only:



arm-linux-androideabi-g++ -DLINUX -E foo.h > temp

      

+3


source


You might be interested in keeping the comments in the preprocessed output (for better readability) with

 arm-linux-androideabi-g++ -DLINUX -C -E foo.h > foo.i

      



then look (with editor or pager) in foo.i

The generated one foo.i

contains lines starting with #

to convey location information.

+2


source


Why not call cpp -D<something to be defined> <header file name>

directly?

0


source







All Articles