macros and defines used in file

Jędrzej Dudkiewicz
Sun Jun 29 19:37:00 GMT 2008


The Story:
I have a large project (C++). It contains about 200 shared files (that
is - code shared by all of components) and 6 components (in fact much
more, but only 6 are compiled on *nix systems). This shared code is
shared only on "file level", as each components requires them to be
compiled with flag "COMPONENT_FLAG" set to different value, i.e.
ComponentNumberOne is compiled with
-DCOMPONENT_NAME=COMPONENT_NUMBER_ONE passed on command line etc. As
compilation of 200 files takes some time, especially on older
machines, and is repeated for each component, there are effectively
1.2k files to compile.

The Problem:
I'm trying to find files that don't depend on value of a macro/defined
value. That is, I'd like to find a way to divide my files in two sets.
Files in one set do not depend on hypothetical "COMPONENT_NAME"
#define, and those in other set do. I tried to do so by setting
"COMPONENT_NAME" to some "strange" value, but it's frequently used in
"#ifdef" directives, where almost anything goes, so this is no good.
Grepping sources also isn't viable, as those directives frequently
control included headers.

So, my question is - is there a way to force cpp or gcc (As I believe
gcc has internal preprocessor, which can do a little more that
standalone cpp?) to show defines and macros used during file
preprocessing, even those, who aren't used because '#if' branching
forbade it? Or is there any other, clever method to do what I want?
(Clever as in "not by hand" :] ).

Jędrzej Dudkiewicz

I really hate this damn machine, I wish that they would sell it.
It never does just what I want, but only what I tell it.

More information about the Gcc-help mailing list