Page tree
Skip to end of metadata
Go to start of metadata

C++ Environment Profiles


A C++ Environment Profiles provide the means to configure two specific C++ analysis variables:

  • Include Paths > configure 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"
    • #include <fileB.h>

    Include Paths can also be administered using the Include option (see C++ Technology editor). Include Paths defined in an Environment Profile will be processed AFTER any definitions made using the Include option.

  • Macros > configure macros that will be used by the internal pre-processor. Macros can also be administered using the Macro option (see C++ Technology editor). Macros defined in an Environment Profile will be processed BEFORE any definitions made using the Macro option.

Notes

  • Please note that a selection of predefined profiles are available. These cannot be modified.
Creating a profile

After clicking the icon next to C++ Environment Profile, a new screen will be displayed containing two tabs:

  • General > For defining a name for the Environment Profile and for defining Include Paths
  • Macros > For defining Macros
General tab

  • Enter a name for the Environment Profile. Choose a name that is easily recognizable as this name will be displayed in the left hand collapsible list and will be used when you add the Environment Profile at Application or Analysis Unit level.

Include Paths

  • Click the icon to choose the path.
  • You can add as many Include Paths as you want (click the icon again).
  • The column Save Called Objects in KB will automatically be selected (a green check mark will be displayed in the list), Recursive will not be activated (see Note below):

    - Recursive indicates that the contents of all sub-folders in your path will be included if selected.
    - Save Called Objects in KB indicates that any objects in the Include Path will be automatically stored in the Analysis Service. As a result you will be able to view the associated links and objects in CAST Enlighten and compute Quality Rules and metrics that depend on them. If you need them only to resolve external references and want to save space in the Analysis Service you should uncheck the option - they will not be stored in the Analysis Service.
  • You can use the button to make an identical copy of a selected Include Path
  • You can use the button to remove a selected Include Path
  • 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 dialog box is the order in which the paths are dealt with during the analysis process.
  • 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 the Windows, this variable will be localized.

To apply the new paths, make sure you click the Apply button. If you want to clear the entire window and revert to the default settings, click the Restore button.

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.
Macros tab

The Macros tab enables you to configure macros that will be used by the internal pre-processor when the associated job is run.

  • Click the icon to create a new Macro
  • The Name column will be activated enabling you to insert a name for the Macro
  • Then click the Value column to enter a value for the Macro.
  • You can add as many Macros as you want (click the icon again).
  • You can use the button to make an identical copy of a selected Macro
  • You can use the button to remove a selected Include Path
  • Force included file

    This section enables you to specify macros in file format:

    Use the 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, .cpp or .h 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, when the analysis is run, the analyzer will search for the file in the current folder and then in the include folders (defined in the Include option (see C++ Technology editor) or in the Environment Profile).

To apply the new Macros, make sure you click the Apply button. If you want to clear the entire window and revert to the default settings, click the Restore button.

Completion

When you have defined the current Environment Profile and have used the Apply button to set the parameters, you can then either create further Environment Profiles or simply close the dialog box.


CAST Website

  • No labels