Imagix 4D User Guide


As with a compiler, the first step in analyzing your code is preprocessing it, transforming it into pure C or C++ software. In this step, preprocessor directives, such as #define, #ifdef and #include are expanded out, and /* comments */ are eliminated.

In order to accurately preprocess the source code, the Imagix 4D analyzer needs some of the same information used by your compiler. The analyzer needs to know where to look for header files. It also needs to know if and how the macros used in conditional compilation directives (such as #if and #ifdef) are defined.

Normally, you pass this information to a compiler through preprocessor flags. The Imagix 4D analyzer uses the same arguments. -Idirname (or /Idirname as an alternative on Windows systems) is used for specifying include directories. These directories are searched, in the order in which they're listed, for the header files referenced by #include statements.

Likewise, the argument -Dmacroname or -Dmacroname=macrovalue is used to define macros, just as with a compiler. These macro definitions are then used for calculating how to process conditional compilation directives, such as #ifdef. -Umacroname, the opposite flag, is also recognized by the analyzer, and causes the macro to be undefined.

By doing both the preprocessing and the actual processing, the Imagix 4D analyzer is able to generate complete information about macros. Consider the following example:

/* this is first line of file */
#define macroB(x) funcC(x)
void funcA(int x)
    int y;
    y = macroB(x);
The analyzer will generate information that funcA uses (calls) macroB, and also that funcA calls funcC. The data files will also contain the information that funcA's call of macroB and funcA's call of funcC both occur at line 7. This later information about where symbols are referenced has a number of applications; among other things, it's used in the Use Browser's display of everywhere a symbol is used.