HP Code Advisor Diagnostics

Accepting an enumerator list that contains a trailing comma is an extension of HP C provided
for compatibility with other C compilers. An enumerator list with a trailing comma is not valid
in C89, nor in C++.The C99 standard does permit this syntax.
Example:
typedef enum Switch {
on,
off,
} var;
Action:
Remove the trailing comma.
Reference:
C99 6.7.2.2 ANSI/ISO C++ 7.2
2231 declaration is not visible outside of function
Cause:
A type is declared within a function prototype. The type is local to the function prototype and
will not be visible outside the prototype. This might cause unexpected errors later in the
compilation.
Example: void foo(struct X { int i; } );
Action:
Declare the type before the function prototype.
Reference:
2236 controlling expression is constant
Cause:
A boolean controlling expression tests for a constant pointer or pointer to member values. NOTE:
This warning is not issued for cases like if (1) ; since these often result from valid macro
expansions.
Example:
void foo();
int main() {
if (foo) { // warning 2236 here.
}
}
}
Action:
A test of a constant address is unusual, and might be done by mistake - check if this is what you
intended.
Reference:
2237 selector expression is constant
Cause:
The given expression in the controlling expression of a switch statement is a constant. Switch
statements are usually used for variables to choose between various alternatives at runtime.
Example:
int main() {
switch(10) {
case 10: printf("ten\n"); break;
38 Diagnostics Details