CMS - C++ Analyzer FAQ
C++ Analyzer FAQ
Q: Are there any limitations with virtual functions?
A: Yes, there are limitations with virtual functions. The limitation that we have is that we are not always able to know which function is called. The following example will provide a clearer understanding of what happens:
class CMother {
public:
virtual void TheFunction() { MessageBox( NULL, “CMother..”, “CMother..”, MB_OK); }
};class CDaugther : public CMother {
public:
void TheFunction() { MessageBox( NULL, “CDaugther..”, “CDaugther..”, MB_OK); }
};void CTestDlg::OnOK()
{
CDaugther cDaugther;
CMother * pcMother=&cDaugther;
pcMother->TheFunction();
}When you run this program, “CDaugther::TheFunction” is called, but in the analysis will return “CMother::TheFunction”.
Q: Are there known issues with regard to “typedef struct {…} b;” code?
A: When an unnamed struct is typedef’ed with an alias, access to the typedef is resolved directly to the underlying struct, and no typedef object is created.
For example:
typedef struct foo {
int bar;
} foo;void someFunc ()
{
foo aFoo;
aFoo.bar = 256;
}Only two objects are created: “struct foo” and “someFunc”, the link from “someFunc” goes directly to “struct foo”. No “typedef foo” object is created:

Q: Are there issues with regard to the internal preprocessor?
A: The internal preprocessor is currently not aware of macros that may be predefined by various compilers, with exception of the standard predefined macros such as __FILE__, __LINE__, __cplusplus, __DATE__, __TIME__, __STDC__ etc.
As a result, when analyzing an application that has been developed using Microsoft Visual C++, it is strongly recommended that you select the appropriate version in the IDE used to create this application option create your own Environment Profile.
Q: Are there differences between the C++ preprocessor and the C preprocessor?
- A: The C++ preprocessor functions in the same way as the C preprocessor and thus leverages C specific features, with the following slight differences:
- The _._cplusplus macro is defined as 199711L in C++ mode - The implementation defined _._STDC_._ macro is defined also in C++ mode and its value is set to 0
- A: Variadic macros (macros of form #define X(param,param2, …) ) are supported in C and in C++ mode.
- A: Empty macro arguments (calling MAC(x,y,z) by the means of MAX(1, ,3) ) are supported in both C and C++ modes.
