Introduction to analysis configuration options
Auto-configuration validationTechnology / Application levelUsing the Technology level or Application level options, validate the settings for C / C++ packages. Make any update as required. These settings apply to the Technology or Application as a whole (i.e. all Analysis Units): 

Analysis Unit levelTo inspect the auto-generated analysis configuration, you should review the settings in each Analysis Unit - they can be accessed through the Application editor: 
Technology optionsNormally, the source code discoverer will auto-configure the Analysis Unit and analysis settings as described above. However, in some circumstances, these settings may be incorrect and must be adjusted manually. The main parameters to work on are as follows: - Source Settings
- Analysis
- IDE used for the Analysis Unit
- STL Support
- Include paths
- Macro definitions
- Precompiled header
- Environment Profile
The available options for configuring an analysis are described below. Note that some options are not available at specific levels (Technology/Application/Analysis Unit). Source SettingsThis tab shows the location of each type of source code in the C / C++ Analysis Unit - this is determined automatically by the CAST Delivery Manager Tool. You should, however, review the configuration and make any changes you need: Click to enlarge: 
Project path | The file based location of the corresponding project. This field is read-only. When the field contains User defined, this indicates that the Analysis Unit has been defined manually instead of automatically following the use of the CAST Delivery Manager Tool. | Consider Files As | C only | If this option is selected, C++ specifics are ignored (templates, namespaces, classes, inheritance and polymorphism) and are not taken into account when the source files are analyzed. This option allows optimized handling of C files. | C++ only | If this option is selected, C++ specifics (templates, namespaces, classes, inheritance and polymorphism) are taken into account when the source files are analyzed. | Both C and C++ | If this option is selected only one distinct job is generated and executed: one C++ technology job using the Consider Files As > C++ option. However the results stored in the CAST Analysis Service will contain both C and C++ object types. In other words, both file types are analyzed as C++ files and Line Of Code Count (LoC) for C files will be included in the C++ technology rather than the C technology. | C File Extensions | Use this option to specify the file extensions that will be considered as C files for analysis purposes. | C++ File Extensions | Use this option to specify the file extensions that will be considered as C++ files for analysis purposes. |
Impacts of choosing one parsing option over the other. Selecting one of these options will cause the source code to be handled differently by the analyzer: - A function or a method contains any number of declarations and at least one definition. The grouping of these blocks in one unique object is done differently by the analyzer according to whether the C++ or C option has been selected:
- With option C, declaration or definition blocks with the same name are grouped together in the same function or in the same method without taking into account any parameters.
- With option C++, declaration or definition blocks with the same name and the same parameters are grouped together in the same function or in the same method.
For example, using the option C++ here would create two functions called "foo" in the Analysis Service schema, whereas using the C option would only create one "foo" function. void foo();
void foo(int a)
{
} |
- The analyzer detects calling links differently depending on whether the C or C++ option is selected:
- With option C, the analyzer believes that the function or the method is called as soon as an object with the same name is called.
- With option C++, the analyzer believes that the function or the method is called if an object with the same name and comparable parameters is also called.
For example (and using the previous example), because using the C++ option with the previous example would create two functions "foo" in the Analysis Service - one with a parameter, the other without - the analyzer will only create a Call type link to the function WITHOUT the parameter. Using the C option, the analyzer will create a link to the one function even if it has parameters. Notes |
AnalysisThe settings in this tab govern how the source code is handled by the analyzer: Click to enlarge: 
Global settingsAnalyzer to invoke | Use this option to choose between the analysis engine that will be used to run the analysis: | Legacy analyzerThis option invokes the legacy C/C++ analyzer as provided in previous releases of CAST AIP and in the C and Cpp Analyzer extension. By default this option will always be active at Technology/Application/Analysis Unit level. Please do not modify this option when using the C and Cpp Analyzer extension. |
| Clang analyzerThis option is only relevant for those that are using the CAST AIP Objective C Extension in order to analyze Objective C source code. This option must be active in order for the Objective C source code to be analyzed by correctly. If this option is invoked and: - the CAST AIP Objective C Extension is not installed, then an error will be displayed when the analysis is run:
The C-Family analyzer is not installed. Please use the Extension Downloader to get it (com.castsoftware.cfamily) |
- the CAST AIP Objective C Extension is installed but your source code does not contain Objective C (i.e. it is a traditional Visual C/C++ application) then results will not be consistent with the output of the "legacy analyzer". In this situation where only traditional Visual C/C++ source code is being analayzed, CAST recommends that the Legacy analyzer option is always used.
| IDE used to develop the Application/Analysis Unit | Use this option to choose the development environment of your source code files. The CAST Management Studio then applies a default Environment Profile (these can be viewed here: <install_folder>\EnvProf\CPP) that matches the selected Development Environment. Note that if the CAST Delivery Manager Tool detects the source code as a variant of Visual C++, then the appropriate option will be set at Analysis Unit level. | STL Support | This option allows you to choose how you want CAST to handle STL header files that are referenced in your source code. Not all other Environment Profiles provided by CAST contain STL header files (for copyright reasons) and this can lead to an incomplete analysis, and thus to incomplete results. As a direct result of this, CAST has introduced this option that allows you to tell the CAST Management Studio whether the STL header files are available or not: | CAST emulation | If STL header files are not available in your source code, select this option. This will then force the CAST Management Studio to activate a basic (i.e. non exhaustive) emulation of the most common STL headers (i.e. <string>, <vector>, <algorithm> etc.), thus avoiding an incomplete analysis or ambiguous/erroneous analysis results in most circumstances. This option is provided via a pre-defined Environment Profile, and you can list the headers that are handled by viewing the contents of the following folder: <install_folder>\EnvProf\CPP\STLforUnix |
| STL already in your Source Code Repository | If STL header files are available in your source code, select this option. The STL header files will be analyzed along with the rest of your source code as normal. This is the default option. | Use Microsoft Managed C++ extensions (CLR) | Select this option if your Source Code contains Microsoft Managed C++ extensions targeted at the Common Language Runtime (CLR). A corresponding Environment Profile will then be applied. See: <install_folder>\EnvProf\CPP\Microsoft Managed C++ |
Note that this option is automatically ticked if the project is configured to execute code under the Common Language Runtime virtual machine. |
IncludesThe options Force Include File and Define the Include Paths enable you to define additional paths for files that have been specified in the #include part of your project files. This is to ensure the correct resolution of links to files located in other directories. The analyzer will take into account the two "include" styles: - #include "fileA.h" > in this case, the analyzer will automatically search the path of the file that contains the #include, THEN the additional paths you have added and in the order specified.
- #include <fileB.h> > in this case, the analyzer will search the additional paths first then, THEN the path of the the file that contains the #include.
The include paths are locations from where the included headers are found. These parameters should be identified automatically from the compilation directives. The files found in these include paths will be saved in the Analysis Service. Thus, the only header paths you should mention here are the header path of the customer applications The C++ Analyzer provides a feature that will scan the source code in order to detect missing header paths and macro definitions. This feature is available through the action Test analysis on the current Analysis Unit in the Execution tab of the Analysis Unit editor. The tools delivered in the CAST Implementation Framework are therefore no longer necessary. |
You should not reference here any third party software header paths (see previous section). Also files that are common to several jobs should be defined in an Environment Profile. Note that include paths defined directly in the job are searched first. Include paths defined in Environment Profiles have a lesser priority. As for the compiler, inclusions defined within "" are searched within the path of the file being analyzed, while inclusions defined within <> aren't. You should also avoid adding more include paths than required: the search for an included file in the include path list occurs regularly and too many unnecessary paths will affect performance. Note that the Include paths are not recursive unless you choose them to be: as such the default behavior is that sub-folders of the folders mentioned in the lists are not considered as potential include paths if not explicitly added to the list (nor are they in the compiler options of the output from the Macro Analyzer, so you should report them as is). However, if you have an include like #include "dir1/file1.h", you should select the directory containing dir1, not the one containing file1. |
Force Include File | This option is used to provide an extra header file which will be appended at the beginning of the preprocessed source, as if each source file were beginning with a #include directive on this file. It is useful in the following cases: - When you have a very large number of macros
- When you have macros that need to be undefined (the GUI here can only define them)
- When the code is using embedded 'C' on Sybase: contrary to Oracle, the Sybase embedded 'C' preprocessor adds some code at the beginning of the generated files. To compensate for this behaviour, you should add the following code in the header used for this option:
- #include <sybhesql.h>
SQLCA sqlca;
You should indicate here the "ExternFunctions.h". If you have several files to "force include", all you need to do is to create an additional file that will include them (using the #include directive) and set this file as being "force included". - Use the Browse button to browse for the file you want to include. This file will contain the macros that you want the analyzer to take into account and must have the same structure as any C/C++ file (in other words, this file can contain "#define" orders to define macros, "#include" orders to include files, but also declare functions).
- It is possible to enter a simple filename (for example test.h) without an absolute path. In this case, the analyzer will search for the file as follows:
- in the associated Source Repository
- then in any defined Include Path (defined in this section or in an Environment Profile defined via the IDE used to develop the application option above or via a Custom Environment Profile defined in the Custom Environment Profiles section below).
| Define the Include Paths used by the Analysis Unit | This option enables you to add your include paths: Adding a path | - Click the button. A new path called "Folder" will be displayed in the list.
- To define the path (using the Browse option) and whether it is recursive or not, select the "Folder" item and use the relevant fields directly below the list.
The Recursive option indicates whether any sub-folders and the files they contain that are located in the chosen path will be included for resolution purposes (TRUE or FALSE). By default all paths that you add to the list will be flagged as FALSE - i.e. their sub-folders and any paths they contain will not be included. Choose whether the path is recursive as appropriate.
Notes - Please note that CAST only recommends selecting the Recursive option if you know exactly what you want to achieve. In the vast majority of situations, you should instead define each include path exactly as it is defined in the C++ project itself.
For example, if your C++ project uses the "comp/include" include path, and your sources reference the file "stat.h" through:
#include <sys/stat.h> // comp/include/sys/stat.h intended
just add the path "comp/include" here, like in your C++ project, without selecting the Recursive option.
Recursive is only useful if you really want to list all subdirectories of a directory, and spare some typing. This is generally not the case.
| Removing a path | To remove a path that you do not want to include in the analysis: - Select the path that you want to remove from the list by left-clicking with the mouse.
- Click the Remove button to clear the selected item(s). The Delete key and the right-click short cut menu can also be used. You can remove multiple items by selecting the items in the list and then clicking the Remove button.
| Editing an existing path | If you want to edit an existing path: - Select the item in the list and use the fields directly below the list to make your changes.
| Up and Down buttons | If you have two or more paths, then you can use the Up and Down arrow buttons to re-order the paths. This is important as the order they appear in the list is the order in which the paths are dealt with during the analysis process. To move a path down one level, select the path, then click Down; to move it up one level, click Up. | Notes- Please note that you can also use the CAST environment variable $(CastCommonDir) when adding an include path. This variable corresponds to the CAST installation folder "%CommonProgramFiles%\CAST\CAST". When you are using a non-English version of Windows, this variable will be localized.
- Note that it is also possible to define persistent Include Paths via a custom Environment Profile (see Custom Environment Profiles section below).
- Note that include paths configured in the current Includes section will be processed BEFORE any definitions made in the Environment Profiles associated to the IDE used to develop the Analysis Unit option, and to any Custom Environment Profiles (see Custom Environment Profiles section) you have added.
|
Defining include paths for Microsoft compilers Usually, if the Microsoft C++ compiler is installed on the analysis machine, you just need to select the default "Microsoft VCxxxx" Environment Profile (via the IDE used to develop the Analysis Unit option above). In some cases, you may also need to provide your include list yourself. The following rules should be followed: - Do not add more directories then required
- Do not select the "recursive" option for these paths
- Do not select a path such as C:\Program Files\Microsoft Visual Studio 10.0\VC\crt\src (this typically contains files that are reserved for Microsoft internal use and debugger)
In any of the three cases above, you will get an error message during the analysis such as: #error directive encountered 'Use of C runtime library internal header file
... (file 'C:\PROGRAM FILES\MICROSOFT[...]\VC\CRT\SRC\CRTDEFS.H")' |
Include paths for Microsoft compilers should resemble the following: For Microsoft VC 9.0 (2008) and higher: - C:\Program Files\Microsoft Visual Studio 10.0\VC\include
- C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include
- C:\Program Files\Microsoft SDKs\Windows\vxx.xx\include
(the third one is for <windows.h> etc., the exact value for xx.xx depends on your exact installation) For older compilers: - C:\Program Files\Microsoft Visual Studio 8\VC\include
- C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include
- C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDKinclude
For even older MS Dev 6 (VC98): - C:\Program Files\Microsoft Visual Studio\VC98\Include
- C:\Program Files\Microsoft Visual Studio\VC98\MFC\Include
- C:\Program Files\Microsoft Visual Studio\VC98\atl\Include
|
MacrosDefine the macros used by the application/analysis unit Use this option to define any macros that are present in your source code and that need to be taken into account during the analysis. Adding a macro | - Click the button. A new macro called "MY_MACRO" will be displayed in the list.
- Define the macro's name and value in the fields that are displayed below the macro list.
| Removing a macro | To remove a macro that you do not want to include in the analysis: - Select the macro that you want to remove from the list by left-clicking with the mouse.
- Click the Remove button to clear the selected item(s). The Delete key and the right-click short cut menu can also be used. You can remove multiple items by selecting the items in the list and then clicking the Remove button.
| Editing a macro | If you want to edit an existing macro: - Select the item and edit the name and value as necessary in the fields that are displayed below the macro list
- You can also double click the macro to right click it and select Edit from the shortcut menu to edit the name and values in a separate editor window.
| Notes- Note that it is also possible to define persistent Macros via a custom Environment Profile (see Custom Environment Profiles - only in the Application editor (Analysis tab) or the Analysis Unit editor)
- Note that macro definitions configured here will be processed AFTER any definitions made in the Environment Profiles associated to the IDE used to develop the Application/Analysis Unit option (see IDE section above), and to any custom Environment Profiles (see Custom Environment Profiles - only in the Application editor (Analysis tab) or the Analysis Unit editor) you have added.
- If you include a file (see below) containing a list of macros, this file is included in each main file that is analyzed. In other words, and for illustrative purposes only, it would be as if each file selected for analysis started with "#include "autoinclude.h" " (where autoinclude.h is the name of the file selected in the Includes section below). These macros are processed AFTER the macro definitions made in this section.
- Most, if not all applications developed with Microsoft Visual C++ rely on a set of (standard or not) header files provided with the compiler (stdlib.h, windows.h...). These headers themselves heavily rely on various macros that are internally defined by the compiler. These macros are predefined via Environment Profiles that are applied automatically to the source code following the selections made in the IDE used to develop the Application/Analysis Unit option (see IDE section above), as such there is no need to explicitly add them.
|
Precompiled Headers (PCH)Precompiled header | Enter the name of a header file, that the majority of the source code files in the project include first, and that self includes many other library files. Typically "stdafx.h" on most Microsoft projects. | PCH generator | A source file that includes the Precompiled header file (as referenced above), and that should be analyzed first. Typically "stdafx.cpp" on most Microsoft projects. | Disable use of PCH | Selecting this option will cause Precompiled headers to be ignored. This is generally not recommended, as PCHs improve analysis speed. |
Custom Environment ProfilesThis option enables you to select C/C++ based Environment Profiles that you have created yourself (as oppose to the Environment Profiles that are pre-defined by CAST and applied when the IDE used to develop the Application/Analysis Unit option is set) Environment Profiles are a set of predefined configuration settings that can be included in an analysis. An Environment Profile can be particularly useful where you have several applications that rely on the same specific settings. By creating an Environment Profile that defines these settings, you then simply include the Environment Profile in the analysis. When the analysis is run, the settings in the Environment Profile are taken into account. For C/C++ technologies, you can define: Add a custom Environment Profile To add a custom Environment Profile: - click the button
- You will be prompted to choose between adding an existing custom Environment Profile (Add option) or creating a new custom Environment Profile (New option):
Add | A dialog box will be displayed listing all existing custom Environment Profiles that have been created:
Select the Environment Profile you require and click OK. The profile will then appear in the list. | Manage Environment Profiles | The Environment Profile Manager will be displayed, enabling you to create your custom Environment Profile: |
Remove a custom Environment Profile To remove a profile that you do not want to include in analysis: - Select the item that you want to remove from the list by left-clicking with the mouse.
- Click the Remove button to clear the selected item(s). The Delete key and the right-click short cut menu can also be used
You can remove multiple items by selecting the items in the list and then clicking the Remove button. Parsing>> allowed to close nested template list | Many compilers allow to close two nested template lists with >> (instead of ">(blank)>" ). There is no reason to deactivate this option, unless "x>>y" is used in any template expression. | Accept Trigraphs | Select this option only if your code contains trigraphs. The analyzer will then interpret normalized character sequences as a single character - for example ??< will be interpreted as {. Note also that this option will also force the analyzer to accept digraphs. | Standard scope of "for" loops | Variables declared inside "for" loops are not visible outside the loop. Activating this option could generate messages about unknown variables on some pre-ISO compilers, like Microsoft VC6. | Standard processing of "typename" | According to the standard, "T::X", not preceded by "typename" (where T is a template parameter) should always be interpreted as an expression. Activating this option is recommended on most compilers, except Microsoft compilers. | Detect unknown compilation directives | When this option is activated, the analyzer tries to detect compilation directives that have not been defined as macros (e.g. WINAPI and the like). Since this option is not 100% reliable, it is recommended to disable it once the analysis has been properly configured. |
ProductionClick to enlarge 
Process SettingsNumber of Instances | This option is only relevant when the "Legacy analyzer" option is active. It allows you to limit the number of objects held in memory before they are committed to disk during the save process of an analysis. Please contact CAST Support before modifying this option. |
Dynamic Links RulesSee the CAST Management Studio help for more information about this global option. |