C and Cpp Analyzer - 2.3


Extension ID

com.castsoftware.cpp

What’s new

See Release Notes.

Description

This extension provides support for C/C++/Pro*C.

In what situation should you install this extension?

If your application contains C/C++/Pro*C source code and you want to view these object types and their links with other objects, then you should install this extension.

Function Point, Quality and Sizing support

  • Function Points (transactions): a green tick indicates that OMG Function Point counting and Transaction Risk Index are supported
  • Quality and Sizing: a green tick indicates that CAST can measure size and that a minimum set of Quality Rules exist
Function Points (transactions) Quality and Sizing

Compatibility

Release Operating System Supported
v3/8.4.x Microsoft Windows / Linux
v2/8.3.x Microsoft Windows

Technical information

Supported technologies

Language Name Versions
icon C C99, C11, C17
icon C++ Up to C++17
icon Oracle Pro*C / Pro*C++ (EXEC SQL commands embedded in C code)
icon IBM Db2 SQC / SQC++ (EXEC SQL commands embedded in C code)

Source code discovery

CAST Imaging will manage the discovery of your C/C++ source code automatically and install the appropriate CAST extensions to detect and analyze your application. The following will be installed/activated by default when C/C++/Pro*C source code is delivered:

In other words, the analyzer supports the following files and appropriate Analysis Units will be created automatically:

  • Microsoft Visual C++ project files such as .vcproj or .vxproj (one Analysis Unit is created per .vcproj or .vxproj file discovered)
  • Some other compiler with only .c, .pc, .ppc, .cpp, .cc, or .cxx files (one single Analysis Unit is created for the root of the source code when any of these files are discovered)

Download and installation instructions

This extension will be automatically downloaded when C/C++/Pro*C source code is delivered.

Analysis configuration

See C/C++ analysis configuration.

What results can you expect?

Objects

Icon Name
Project
Folder for Classes, Unions and Structures
Dependencies Folder
Globals Folder
File Scope Folder
File
Class
Method
Function
Macro
Global Variable
Member
Destructor
Constructor
Struct
Union
Enum
Enum Item
Typedef
Template Parameter
Class Template
Function Template
Method Template
Constructor Template
CLR Event (Managed C++)
CLR EventAddon (Managed C++)
CLR EventRaise (Managed C++)
CLR EventRemoveOn (Managed C++)
CLR Property (Managed C++)
CLR PropertyGetter (Managed C++)
CLR PropertySetter (Managed C++)
SQL Query

Structural rules

The following rules are provided in the extension:

Log messages

Issue 1: Analysis stops prematurely while executing a C/C++ analysis

During an analysis errors can occur that stop the analysis process:

Message Description Message Level Impact Resolution
Analysis canceled on user request. The analysis has been canceled by the user. Error The analysis ended. Restart the analysis.
Run-time exception occurred, analysis canceled: <reason> The analysis crashed. Error The analysis ended without any result. Contact Support.
Please take a copy of the file ‘PATH’ and send it to CAST, to help analyze the issue. This message is associated with the analysis crash above. Please send support the preprocessed file mentioned in the error message. Error The analysis ended without any result. Contact Support and send them the preprocessed file.
Unknown exception occurred, analysis canceled. The analysis crashed. Error The analysis ended without any result. Contact Support.
Fatal error: <reason> The analysis crashed. Error The analysis ended without any result. Contact Support.
Analysis canceled. The analysis has been canceled. Error The analysis ended without any result. Restart the analysis. If you face the problem again, then contact Support.
Invalid positions (start, end) found for object NAME when computing CRC: <list of positions> Internal error. Error The result of the analysis will be corrupt. Contact Support and send them the preprocessed file.
Parser error \ Parsing error. Error The result of the analysis can be corrupt. Contact Support and send them the preprocessed file.
Some unexisting paths where found in the configuration. This error will occur when you have manually added Source code, Includes or Macros to the analysis configuration and these items point to a code location that either no longer exists or cannot be accessed when the analysis is run. Typically this occurs when analyzing Vn+1 of the Application and the Deployment folder changes location between versions: if the Source code, Includes or Macros point to the previous Deployment folder, then the error occurs. Error The analysis ended without any result. Update and correct the location of the manually added Source code, Includes and Macros and then re-run the analysis.

Issue 2: Missing source code

Situation is clear: either you don’t have the complete source code or there is a mismatch between the Operating System you have configured the Analysis Unit for and the system headers you are using:

Message Description Message Level Impact Resolution
“Invalid include path <path>, declared in environment profile ‘PROFILE’ The path of the included file is not correct. Please correct it. Error The results of the analysis may be corrupt. Correct the definition of the profile or select another profile.
Configuration <message> (during the phase of parsing) A macro or an include file it is not correctly defined. Probably an include file is missing. Error The results of the analysis will be corrupt. Correct the configuration or define the missing macro.

Issue 3: Configuration problems

Sometimes the whole source code is available but issues related to the configuration can occur:

Message Description Message Level Impact Resolution
Unable to open file <name of the file>. Unable to open the file. Error The result of the analysis will be corrupt. Check that file is accessible (network, permissions etc.) or call Support.
“Unable to open file ‘PATH’ and to compute CRC. Reason: Unable to open the file. Error The result of the analysis will be corrupt. Check that file is accessible (network, permissions etc.) or call Support.
Preprocessor cannot find file <name of the file> An included file is missing. Warning The result of the analysis may be corrupt. Add the file or correct the include path.
Following file(s) is/are selected for analysis, while being also included by other analyzed file(s). This could lead so some inconsistencies in the analysis, if they are parsed with different preprocessing contexts (e.g. different macro definitions).
Maybe you want to consider removing that/these file(s) from the selection: POSLIST
Following file(s) is/are selected for analysis, while also being included by other analyzed file(s). Warning The result of the analysis may be corrupt. Correct the analysis configuration.
Trying to include a precompiled header from another place than the start of the compiled file (file <path>’, line <line>). This can cause strange behavior. PCH usage deactivated. This usually occurs when a file that is included, itself includes a .pch. This usually would happen in files such as .hpp or .c files.
What customer can do: Not include .pch from file that is included.
Warning No impact. Avoid including .pch in the source code where possible.

Issue #4: There are some ambiguities with regard to object names

Issues can occur at analysis time with regard to object names. This probably means that:

  • Either you have issues in the macro on portable code (i.e code meant for multiple Operating Systems): some functions are defined several times (one for each Operating System) and the macros prevent the analyzer from only considering one of them.
  • Or (less probable) you have some code that relies on some specific properties of the compiler (which is indeed bad practice).
Message Description Message Level Impact Resolution
Empty variable name encountered (is that a C++ file?) Error concerning the empty variable names, most probably due to an earlier parsing error . Warning The result of the analysis will be corrupt. Correct the analysis configuration.
Multiple definitions found for ‘NAME’. A link will be traced towards each of these definitions: <list of positions> Resolution error. Warning Unwanted links can be created. Contact Support.
Several definitions found for symbol <symbol mangling>:<list of positions>
References to that symbol will be duplicated in some cases.
Multiple definitions found for the same object inside different source code. Warning The analysis will contain unwanted links. Split the Analysis Unit into several parts.
Several definitions found for <name of object>. Two objects will be created: <list of positions> Multiple definitions found for the same object inside the same source code. Warning The analysis will contain unwanted links. Split the Analysis Unit into several parts.
Unresolved identifier <name of identifier> Resolution error. Some source code may be missing. Warning Some missing links. Correct the analysis configuration or contact Support.
Function <name of the function>() is called without having been declared. This message concerns only the C language. An include file is missing or the file uses C feature unrecommended. Warning There is no impact. Check the analysis configuration.
No parent class nor namespace found for method/function <name of the method>. Object will be saved under its parent file only. The source code is not complete. Most of the time headers with class definitions are missing. Warning The result of the analysis may be corrupt. Correct the analysis configuration (the include paths).
Unknown identifier <name of the identifier> is now considered as a type. The parser has corrected a missing macro definition or a missing include file. Please complete the macro definition list in order to remove the warning. Warning No impact. Correct the analysis configuration.

Issue #5: Memory problems

If you are experiencing memory issues during an analysis, CAST recommends using RAM monitoring tools while running the analysis to check if the process is using more than 1.9 GB of memory.

If this is the case, it means that the Analysis Unit is too big in terms of file size or file number - you will need to split the Analysis Unit into multiple smaller Analysis Units.

Issue #6: Other problems

If you are still experiencing problems and none of them concern the topics above, then please check the messages below:

Message Description Message Level Impact Resolution
Unable to access list of system functions implied in diags (strcpy, gets…). Some of these diags could be inconsistent. The analyzer cannot access the list of system functions. Error The result of the analysis will be corrupt. Contact Support.
Flag ‘recursive’ has been set for include path ‘PATH’. This flag is generally of no use and this is generally an error to set it. The order defined for the included files is not correct. Warning The result of the analysis will be corrupt. Remove the “recursive” flag.
File <name of the file> has no executable code. The files only contain function definitions, macros or comments. Warning The result of the analysis may be corrupt. Check the analysis configuration.
"[Parser] XXX: Single operand or parenthesized expression expected."

"[Parser] XXX: Nonstandard untyped declaration, "int" assumed."

"[Parser] XXX: Ignored token 'XXX'"

"[Parser] XXX: Variable has already a name"
Generally these type of messages are not blocking and usually mean that a defined macro or a header file is missing. Warning Potentially missing links. Check the analysis configuration and the delivered source code.