Imagix 4D User Guide

Step 2 - Dialog-Based Approach (C/C++)

The most generic approach for specifying your source code and how to analyze it is the Dialog-Based approach. It involves filling out a dialog, where you'll specify:

  • the directory where the source files are located
  • the names of the source files (using *.c style expansions)
  • the -I, -D and -U preprocessor flags to use

2a. Specify that you're adding a new data source

Open the Data Sources dialog (Project > Data Sources). To specify that you wish to add a new data source into the project rather than modify the settings for an existing data source, choose `+ new data source' under the Data Sources selector on the left side of the dialog. As this is a new project, and there are no existing data sources to modify, this is indeed the only choice available.

2b. Select the dialog-based approach

For the rest of step 2, you'll be working on the right side of the Data Sources dialog. At the top, select [Source Files][Dialog Based (C/C++)] in the menubutton labeled `Select Data Source Type'.

2c. Specify which source files you want to analyze

In the Source Files tab, use the Directory field to enter the name of the directory where your source code is located.

Note: If your source code spans several directories, you may be able to take advantage of the `Analyze files in subdirectories' just below the Directory field. If the code you want to analyze is spread across a directory and its subdirectories (and their subdirectories), enter the name of the top-level directory in this Directory field. If there are certain subdirectories that you want to omit, specify them through the Exclude dialog. Depending on how your source code is spread across your directory structure, you may need to repeat step 2 for each directory containing code you want to analyze.

In the Source Files field, enter the names of the source files. Patterns with * characters are expanded, for example `*.c' expands to a list of all the .c files in the directory. You may enter multiple names and/or patterns, separating them with spaces such as `*.c *.cpp'. You don't need to specify the .h files. The analyzer will automatically analyze any .h file that is included by one of the .c or .cpp files you specify, as long as it is located in one of the include directories specified in step 2f.

2d. Specify the -D and -U flags to use in analyzing your source code

Still on the Source Files tab, in the PP Flags field, enter `-Dmacroname -Umacroname' as appropriate. You may enter as many -D and -U's as you wish. Do not put a space between the -D or -U and the following name. Put a space between the name and the next -D or -U.

The -D and -U flags cause macros to be defined or undefined. If you're defining a macro replacement value for a macro name, such as -Dmacroname=value, do not put a space on either side of the = sign.

2e. Select your compiler configuration file

In the Compiler & Target combobox, select the compiler configuration file that you set up in step 1. If you haven't yet configured a compiler configuration file for the compiler and target platform of your software, strongly consider doing so now. The alternative is to select `other'. If you select `other', you'll need to specify the implicit flags in the PP Flags field (step 2d).

2f. Specify the locations of the header files you wish to include

As noted in step 2c, normally you don't explicitly direct Imagix 4D to analyze header files. Instead, you rely on the #include statements in the source code, and simply specify which include directories to search for the included header files. This is specified in the Include Dirs tab.

The Include Dirs tab gives you two ways to specify these directories. You can use either of these methods, or both together. If your header files are spread across a directory and its subdirectories (and their subdirectories), you'll probably want to use the `Specify Include Directories By Root Directory' portion of the tab. Enter the name of the top-level include directory in this Directory field, and complete the `Search subdirectories for header files' and the `Exclude' dialog as appropriate.

If your header files are spread across scattered include directories, or if you want control over the order that the include directories are searched, use the `Specify Include Directories Individually' field, to enter `-Idirname1 -Idirname2' as appropriate. You may enter as many -I's as you wish. Do not put a space between the -I and the directory name. Put a space between the directory name and the next -I. If you're running under Windows, and the directory name contains a space, enclose the -Idirname with double quotation marks, such as "-Ic:/program files/msvc/include".

The -I flags tell the analyzer which directories to search for include files. They are searched in the order that you list them. Path names relative to the Directory field on the Source Files tab are supported, such as `-I../parallel/example'.

2g. Start the analysis process

At this point you're ready to invoke the analyzer. However, analyzing your code often turns up errors in your settings, particularly how you have specified you include directories and your -D flags. You may find it preferable to load just a subset of your code first. If so, go to the Files field on the Source Files tab, and specify just one particular file to analyze in the first pass.

When you're ready to analyze your code, click Add Data Source at the bottom of the dialog.