| |||
| Home > C and C++ Compilers > Command syntax > Controlling error messages | |||
The compiler issues errors to indicate serious problems in the code it is attempting to compile. The compiler options described below enable you to:
turn off specific recoverable errors
downgrade specific errors to warnings.
These options force the compiler to accept C and C++ source that normally produces errors. If you use any of these options to ignore error messages, it means that your source code does not conform to the appropriate C or C++ standard.
These options can be useful during development, or when importing source code from other environments. However, they might permit code to be produced that does not function correctly. It is generally better to correct the source than to use options to switch off error messages.
The general form of the -E compiler option
is:
-E[options][+][options]
where is
a set of one or more of the letters optionsa, c, f, i, l, p,
or z as described below.
If the + character is included in the characters
following the -E, the error messages corresponding
to any following letters are enabled rather than suppressed.
The -E option on its own without any options
is the preprocessor switch. See Setting preprocessor options.
You can specify multiple options. For example:
-Eac
turns off the error messages specified by a and c.
The following options are on by default:
-EaFor C++ only, this option downgrades access control errors to warnings. For example:
class A { void f() {}; }; // private member
A a;
void g() { a.f(); } // erroneous access
C3032E: ’A::f’ is a non-public member
-EcThis option suppresses all implicit cast errors, such as implicit casts of a nonzero int to pointer.
C3029E: ’=’: implicit cast of non-0 int to pointer
-EfThis option suppresses errors for unclean casts, such as short to pointer.
-EiFor C++ only, this option downgrades from error
to warning the use of implicit int in constructs such
as const i;.
C2225W: declaration lacks type/storage-class (assuming 'int'): 'i'
-ElThis option suppresses errors about linkage disagreements where functions are implicitly declared as extern and then later redeclared as static.
C2991E: linkage disagreement for ’f’ - treated as ’extern’
-EpThis option suppresses errors arising as the result of extra characters at the end of a preprocessor line.
-EzThis option suppresses the errors caused by zero-length arrays.
C3017E: size of a [] array required, treated as [1]