Loading in Your C/C++ Code

Once you have created an empty new project, there are three main steps for populating the new database with information about the source code that you want to analyze.

1. Select and configure a compiler configuration file

Imagix 4D's source analyzer itself does a compiler independent semantic analysis of your source code. Through compiler configuration files, the analyzer is extended so that it behaves like your compiler. The result of this is that Imagix 4D's analysis of your software matches that of your compiler.

Selecting and configuring a compiler configuration file is a one-time activity. You can use the resulting configuration file to load in any of your source code that you compile with that compiler.

2. Specify your source files and how to analyze them

The central step in importing your source code into Imagix 4D is having the tool analyze your source code. The Imagix 4D analyzer semantically parses your code, much like a compiler. Just like with a compiler, you'll pass it a list of source files, along with a list of options indicating where to look for include files, and what macro definitions to use in the analysis. Whereas a compiler generates object files that are later linked into an executable, the Imagix 4D analyzer creates data files, which are later loaded and integrated in the Imagix 4D database.

For C and C++ code, there are a several different approaches available for specifying your source code and how to analyze it.

Extract from Build Log

If you have an environment where you can compile your code, the recommended approach is to capture the commands sent to the compiler, and derive commands for the Imagix 4D source analyzer based on those commands. While compiling your code, you may have a way to directly capture the build-issued commands into a build log file. If not, you can use the imagix-cc-monitor utility to monitor system commands and capture any compiler invocations to a file. Whichever way you generate the build log file, this approach automatically processes that file, analyzing the compiler invocations, and identifing the source file and -I, -D and -U arguments passed to the compiler. Applying this information, a series of data source entries are defined, one for each group of source files sharing similar flags. These are the same data source entries that you would fill out manually in the Dialog-Based (C/C++) approach. By populating them automatically from the build log, you are assured that the settings match how your compiler analyzes the code.

Recommended if you can compile your source code

Import from Microsoft Visual Studio

The Extract from Build Log approach includes special support for working with Microsoft Build generated logfiles. So if you're using the Microsoft Build tools together with the Microsoft Visual Studio, Extract from Build Log remains the recommended approach. But if you're not able to compile your code to generate the necessary logfiles, a second approach is available for Microsoft Visual Studio (MSVC) projects and solutions. This alternative extracts the file and preprocessor flag information directly from the makefile, .dsp, .vcproj or .vcxproj file created by Visual Studio. For solutions (called workspaces prior to the .NET version), .dsw or .sln files are read.

Recommended if you can't compile your code, but you already have Microsoft Visual Studio projects defined for the code

Dialog-Based (C/C++)

A third approach is the most generic. It also involves filling out a dialog, but here it is done manually. In the dialog, 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

Recommended if neither Extract from Build Log nor Import from Microsoft Visual Studio apply

Add Targets to Makefile

A final approach uses your make system actively rather than passively, by adding targets to your makefiles. Since your makefile contains information about source files and preprocessor flags, this fourth approach leverages the already existing definitions. While the makefile approach offers some advantages in on-going production use of the tool, it is generally much more difficult to get started with, and is not recommended for initial evaluation of the tool.

Recommended only if dialog-based approach does not yield sufficient precision

3. Adjust the project settings to refine the analysis results

Once you have defined your project settings and started the analyzer, any issues encountered by the analyzer will be reported to the Analyzer Results window. You can use these reported results to fine-tune your project settings and achieve a more precise representation of your software.