gccmakefileg++

Find if the code under a macro is getting compiled


I have a large base of code for a series of embedded devices. Everytime we make a fix for one product, we merge-in the changes for others. Sometimes, some devices have the code under Macro's .. something like

#if DEVICE1
   Do_This();
#elif DEVICE2
   Do_That();
#else
   Do_SomethingElse();
#endif

In the above case, I will have to merge-in the code under resspective macro. Sometimes, it is not very stright forward. So, after merging-in the changes.

During compilation time, is there any way to find whether the new added lines of code getting compiled or not?


Solution

  • cpp is the same preprocessor used by gcc. Call it manually with the same flags, it will output resulting (processed) code. Search interesting area to check what you want.

    E.g. cpp foo.c | less.