Step 1 - Adjust a Compiler Configuration File

First a warning - for C and C++ software, correctly specifying the preprocessor flags is the most conceptually and technically challenging part of loading in your code.


When you compile your source code, your makefile, build script or IDE passes a series of -I, -D and -U flags to your compiler, along with a list of source files. These flags are used by the compiler to determine where to look for header files, and what macro definitions to use in analyzing your code.

These macros are used in conjunction with #ifdef statements to control which portions of your source code are processed, and which are ignored by the analyzer's built-in preprocessor. For example, if you have entered `-Dfoo' in the PP Flags field, and your code contains a `#ifndef foo', the code following will be skipped until the corresponding #endif is reached. Later, in step 2, you'll specify the flags that are passed by your build script or makefile.

In addition to these explicitly passed preprocessor flags, your compiler also uses some implicit -I, -D and -U flags of its own, which are necessary for locating and accurately analyzing the system header files.

The Imagix 4D analyzer is compiler-independent. By specifying where to find the compiler-specific header files, and what macro definitions to use in analyzing them, the Imagix 4D analyzer is able to match the behavior of your compiler.

See Compiler Configuration Files for further background. Also, there is a special utility for gcc-based compilers and special instructions for Microsoft Visual C++.


There are two ways to set up the analyzer to do this. The first is to add these implicit, compiler-added -I, -D and -U flags when you specify (in step 2) the regular -I, -D and -U flags that are explicitly passed to your compiler.

The second, strongly recommended, approach is to make use of Imagix 4D's compiler configuration files (.inc files). In this approach, you specify system header file locations and macro definitions in a configuration file, and then use the Data Sources dialog (Project > Data Sources) to specify which configuration file to use.

These configuration files are located in the ../imagix/user/cc_cfg directory. There, you will find a series of .inc files. The base name of the file indicates the compiler and the target platform supported by that particular configuration file.

You can add configuration files of your own, as well as modify any of the supplied configuration files. Typically, you'll need to change the system include directory locations defined in the supplied files to reflect where the system header files are actually installed in your environment.

There are several advantages to using the compiler configuration file approach rather than simply adding the implicit, compiler-added -I, -D and -U flags to the regular -I, -D and -U flags. First, if there's already a configuration for your compile environment, it saves you some work. Secondly, you only need to specify the information once for your environment, rather than each time you create a new project. And finally, it makes iteratively fine-tuning your settings easier.

1a. Select a compiler configuration file

Go to the ../imagix/user/cc_cfg directory. Look for a configuration file that matches your environment.

If you're using a gcc-based compiler, running the ../imagix/bin/imagix-gnu utility will automatically query your compiler and build a configuration file specifically tailored for your compiler / environment.

If you don't find a good match, create one with a name that represents your compiler and target. Although you could start with an empty file, typically there will be an existing configuration file for a similar compiler / target that you can copy and then modify.

1b. Adjust the paths for the systems header files

Once you have chosen or created the configuration file, modify it so that the include directory locations match your environment. Near the beginning of each .inc file is a line or set of lines where the header file locations are specified.

Here's a simple example from the file:

/* ##################### USER-MODIFIED SECTION ##################### */
/* normally, you'll make changes here to reflect your environment    */

/* specify the location of the system header files */
#pragma cmdflag -S/usr/arm/include

The content of the .inc file is processed as C code. The include directories are specified by the #pragma cmdflag -S... lines. Together, the #pragma cmdflag specify that what follows on the line is to be processed as an option by Imagix 4D's source analyzer. The -S option is used to specify system include directories. This distinguishes them from normal (application) include directories specified with the standard -I option.

In this example, only one include directory, /usr/arm/include, is specified. If you're running under Windows, you would need to change this to the appropriate Windows directory, which, depending on your environment, might be something like:

/* specify the location of the system header files */
#pragma cmdflag -SC:/Keil/ARM/ARMCC/include

Adding an additional include directory is done by inserting a new line into the .inc file:

/* specify the location of the system header files */
#pragma cmdflag -Sc:/tools/arm/include
#pragma cmdflag -Sc:/tools/thirdparty/include

When multiple include directories are listed, they searched in the order that they appear in the file.

1c. Make any other adjustments

In the opening sections of many of the configuration files are a number of defines to match specific processors and compiler options.

Here's an example from part way into the file:

/* specify one target processor or instruction-set architecture (uncomment one) */
/* #define __RX200     */
/* #define __RX600     */
/* #define __RXV1      */
/* #define __RXV2      */

/* ################### EXTENDED MODIFIED SECTION ################### */
/* you may choose to make changes here to reflect common options     */

/* specify miscellaneous compiler options (uncomment any).
   these can also be invoked via command line switches,
   for example __IMGX_endian$61big__ is equivalent to -endian=big.

/* #define __IMGX_endian$61big__ */       /* set endian type for data to big */
/* #define __IMGX_round$61zero__ */       /* round to zero */
/* #define __IMGX_denormalize$61on__ */   /* enable denormalization */
/* #define __IMGX_dbl_size$618__  */      /* handle double with double precision */
/* #define __IMGX_int_to_short__ */       /* replace int type with short */

By commenting / uncommenting particular defines, you can set up the .inc files to match particular processors and particular configurations.

Later, in step 3, you may need to fine-tune the .inc file through a process of reviewing the analysis results and reading your compiler's documentation. More detailed information about customizing a compiler configuration file can be found in the readme.txt file in the ../imagix/user/cc_cfg directory.