4.7. C/C++ Compiler Definitions

Sonargraph uses internally the Edison Design Group (EDG) C/C++ Front End to parse C/C++ sources. In order to emulate the behavior of your C/C++ compiler, Sonargraph needs a compiler definition. A compiler definition contains the location of the directories containing the system include files, a list of predefined macros and other options for the EDG parser defining language features and compatibility levels. You will not be able to successfully parse a software system without a proper compiler definition for your compiler. One compiler definition has to be set as the "active" definition, which will be used by default for opened software systems containing C/C++ modules.

Sonargraph comes with pre-defined compiler definitions that are activated by default depending on the platform Sonargraph is running on:

  • "CLang" for Mac OS-X.

  • "GnuCpp" for GNU C++ compiler on Unix based systems (Linux, Unix).

  • "VisualCpp_x_y_z" for Windows based systems that have Microsoft Visual Studio Compiler installed. (x = version, y=architecture, z=processor, e.g. VisualCpp_12.0_x86_amd64). These definitions will not be automatically generated anymore because from Visual Studio 2019 on it is not possible anymore to query the registry for the installation location of Visual Studio. You have to tell Sonargraph where Visual Studio is installed. You can even register different Visual Studio versions with Sonargraph. To register an installation use the "Visual Studio Installations" preference page under the C/C++ preference page group. To get there just select "Preferences" from the "Windows" menu. You then add the root directory of each Visual Studio installation you would like to use with Sonargraph. The root directory must have a sub-directory "VC".

If you are using a different compiler the easiest way to create a new compiler definition is to use the wizard under the "File/New/Configuration..." menu. If you have used our old product Sotograph before the wizard offers you to import a Sotograph compiler definition into Sonargraph. If you do not have a Sotograph compiler definition file you can ignore this step.

In the "Preferences..." menu, you can manage and modify existing compiler definitions or create new ones based on existing compiler definitions.

C++ Compiler Definition
Figure 4.5. C++ Compiler Definition


The translation tab allows to define how options retrieved from imports need to be handled: For C++ modules created based on imports (e.g Makefile or Visual Studio 2010 project files (.vcxproj)), only macro (-D) and include (-I) preprocessor options will be applied. Use the translation functionality if any additional options of the imported project are required for parsing or the EDG parser uses a different value than your standard compiler.

For certain compilers it is possible to dynamically retrieve predefined macros and the include search path. To do that compiler definitions can be based on Groovy templates that invoke the compiler to query those settings. This is of course not possible for all compilers. Therefore we also have created a compiler definition wizard that will collect the information about the compiler to be emulated from you. You can invoke this wizard from the "File""New""Configuration..." menu. The wizard also supports the import of compiler definitions from Sotograph. (Previous tool from hello2morrow)

NOTE

You need to "activate" a compiler definition to use it for parsing. Just selecting a definition is not enough.

NOTE

Replacing the active compiler definition or modifying its content will force a reparse of the currently loaded software system as soon as the compiler definition is activated or the changes are applied.

By default, compiler definitions are stored in the Sonargraph home directory. These definitions are not intended to be shared. If you want to share compiler definitions across team members, it is recommended to specify a separate directory in the search path that contains these shared definitions. See Section 4.8, “Search Path Configuration” .