This chapter describes diagnostic messages generated by the SAS/C C++ Development System and SAS/C C++ Cross-Platform Development System. Translator diagnostics identify program errors such as missing or misplaced tokens, extraneous tokens, and type mismatches but cannot tell you whether your programming logic is correct.
Each diagnostic includes the message number and text, the error level (for example, ERROR or WARNING), an explanation of the message, and if possible, a solution.
C++ diagnostic messages have the form
LSCTmessage-number severity: message-text
If the translator generates one or more error messages, the source program is incorrect and translation is terminated without producing a compiled output file. Warning messages, on the other hand, indicate potential problems which may not affect how the program is compiled, linked, and executed.
You should fix the errors in the order they appear on your display or listing. Sometimes a single error in your program can result in multiple error messages. The translator attempts to pinpoint the line number in which the error occurred, but occasionally, the error may occur in a line before the line number given by the translator.
Note: Some messages refer you to additional information in the reference section of Bjarne Stroustrup's The C++ Programming Language, Second Edition (CPL2).
The C++ message prefix (LSCT
) has been omitted from the following descriptions.
ERROR: Illegal token.
ERROR: Can't find file: file-name.
#include
directive cannot be found.
ERROR: Invalid file name.
#include
directive must be enclosed in double quotes ("") or angle brackets (<>).
See the information on header files in Chapter 4, "Standard Libraries,"
of the SAS/C C++ Development System User's Guide for information
on when to use quotes or brackets.
ERROR: End of file encountered in comment.
WARNING: Invalid escape sequence.
ERROR: Illegal preprocessor directive.
WARNING: Extra token(s) after preprocessor directive.
#if
, #else
, or #endif
directive has been followed by some text not within a
comment.
ERROR: Missing identifier in preprocessor context.
#if defined
instead of #if defined myfunc
, this message
is issued.
WARNING: Redefinition of preprocessor symbol: symbol.
ERROR: Redefinition of preprocessor symbol: symbol.
ERROR: Missing ')' in macro call.
ERROR: Missing argument to preprocessor macro.
ERROR: Missing comma in preprocessor expression.
ERROR: Illegal operator in preprocessor context.
ERROR: Missing operand in preprocessor context.
ERROR: Illegal expression in preprocessor context.
ERROR: Preprocessor number not a true number.
ERROR: Integer required in preprocessor expression.
ERROR: Extra #else or #elif.
#else
or #elif
directive has been found without a matching #if
directive.
ERROR: Extra #endif.
#if
directive.
ERROR: Invalid #line format.
#line
directive. The form of the #line
directive is
#line-number "string"where line-number must be an integer constant and string must be enclosed in double quotes.
ERROR: Missing parenthesis in preprocessor expression.
ERROR: Illegal use of # operator.
ERROR: #error directive.
#error
directive. This message is issued whenever
a #error
directive is encountered.
ERROR: Illegal ## expression.
##
operator is missing. This may happen if the
##
expression begins or ends the line.
ERROR: Illegal operand of ## operator.
##
expression is not an identifier. You may have misspelled the
identifier.
WARNING: Unterminated string or character constant.
ERROR: Unterminated string or character constant.
WARNING: No file-name include file directories specified.
ERROR: Character literals must contain at least one character.
ERROR: Unterminated preprocessor conditional.
#elif
directive) was pending. One or more #endif
directives are missing.
ERROR: Integer value out of range.
ERROR: Constant too large for data-type.
ERROR: Illegal use of ## operator.
##
operator was not a valid preprocessor
token. This may occur, for instance, when an operator token is
pasted to an identifier token.
Warning: More than two filename arguments (extras ignored): file-name.
Warning: Invalid option-type option (ignored): option-name.
WARNING: No such message #message-number, in option option-name. Option (ignored).
WARNING: Cannot negate the option-name option (ignored).
ERROR: Cannot operation the file-type file named 'file-name'.
ERROR: Cannot construct the default operation filename from the operation filename 'file-name'.
WARNING: Option option-name ignored because it is incompatible with option option-name.
ERROR: Cannot use output file file-name because it has a record length of one(1).
WARNING: Invalid SNAME: section-name.
ERROR: Invalid file-name fileid: file-ID.
WARNING: Syntax error explanation.
ERROR: Syntax error explanation.
Because any #pragma
not recognized by an implementation must be ignored,
diagnostics pertaining to #pragma map
and #pragma linkage
are issued as
warnings rather than errors. However, you should treat them as errors because no action is
taken on a faulty #pragma
of this sort.
WARNING: Syntax error in #pragma directive: explanation
#pragma
not recognized
by an implementation must be ignored, diagnostics pertaining to #pragma
map and #pragma
linkage
are issued as warnings rather than errors. However, you should treat them
as errors because no action is taken on a faulty #pragma
of this sort.
WARNING: Invalid #pragma linkage directive. Use an extern [OS] linkage specifier for C++.
#pragma
linkage construct
was found for OS
linkage. The #pragma
linkage construct is
valid only for C code. In C++, the identifier should be declared with an
extern "OS"
linkage specifier or with the _ _ibmos
keyword.
The #pragma
may not have the intended effect in all circumstances.
ERROR: Newline within string or character literal.
ERROR: Bad character in input hex-value.
WARNING: Asterisk found as first character of C++ style comment.
/* */
) instead of a
C++ style comment (//
).
WARNING: C style comment starting on line line-number never ends.
*/
sequence to the comment. Either you have forgotten
the comment terminator or you intended the comment to be a C++ style comment.
ERROR: 'identifier-value' not declared.
ERROR: No such class: 'identifier-value'.
::
operator or in a base-specifier-list.
ERROR: 'struct' or 'class' used on 'enum identifier-value'.
enum
tag, but the keyword struct
or class
was used
instead of enum
.
ERROR: 'enum' used on 'class identifier-value'.
enum
was used
instead of struct
or class
.
ERROR: 'identifier-value' previously declared to be a type-name.
ERROR: 'identifier-value' redefined.
ERROR: Scoped declaration in parameter list.
::
operator cannot be used in parameter lists.
ERROR: Label 'label-name' not defined.
goto
statement in the previous
function, but the label was never defined in the function. Labels are defined in a function
using the label : statement
notation.
ERROR: Label 'label-name' previously defined.
ERROR: Repeated keyword or type name: 'keyword'.
ERROR: Conflicting keywords or type names: 'keyword-1' and 'keyword-2'.
ERROR: Must be integral, pointer, or member pointer.
?:
operator and as the test for the if
,
while
, do while
, and for
statements.
ERROR: Must be integral.
case
label
and in the test expression of a switch
statement.
ERROR: No such conversion: to (type-1) from (type-2).
ERROR: Expression is not modifiable.
ERROR: Invalid use of '&' address-of operator. object.
ERROR: Cannot initialize variable with initializer.
ERROR: Preprocessor error.
ERROR: Unexpected end of file.
WARNING: A non-lvalue array was converted to a pointer.
operator[]
should not be applied
to it because operator[]
requires a pointer. Also the array should not
be assigned to a pointer variable. If you want only to access the array,
you may ignore this warning. However, if you want to alter the value of
an array element, you should treat this message as an error.
ERROR: The base name 'class-1' is ambiguous in class 'class-2'.
ERROR: Conversion from a virtual base class 'class-name' to a derived class is not allowed.
ERROR: Ambiguous conversion to integral type from 'class class-name'.
ERROR: Ambiguous conversion to pointer from 'class class-name'.
ERROR: Ambiguous conversion to testable from 'class class-name'.
ERROR: Ambiguous conversion to derived member pointer.
ERROR: Ambiguous conversion of overloaded function pointer.
ERROR: Ambiguous conversion to class.
ERROR: Ambiguous conversion.
ERROR: Ambiguous function call.
ERROR: Overloaded functions 'function-1' and 'function-1' used ambiguously in conditional expression.
?:
). These overloaded functions have more
than one function type in common. Cast one or both operands to the
desired function pointer or member function pointer type.
ERROR: Ambiguous common base class: class-name.
ERROR: Ambiguous member name: member-name.
ERROR: Non-static member 'member-name' must be used with dot, arrow, or address-of operator.
-static
members can be used only in the following contexts:
&class-name::member-name
)
sizeof
or offsetof
expression
-static
member function of a class that contains or inherits the member
(where the this->
operation is implied).
ERROR: Value of an undefined class cannot be used.
ERROR: An array may not be the target of an assignment.
ERROR: A function may not be the target of an assignment.
ERROR: Cannot operation a pointer to type.
void
, a function
pointer, or a pointer to an undefined class. Nor can you use the
indirection operator (*) on a pointer to void
or a pointer to an
undefined class. The error message explains which of these mistakes you
have made.
ERROR: Typedef names cannot be declared in parameter lists.
typedef
name has been encountered in a parameter list. Move the definition of the
typedef
name outside the parameter list (that is, to file scope).
ERROR: Cannot take the address of a member of virtual base class.
ERROR: Invalid initializer.
ERROR: Invalid use of void.
void
.
ERROR: Cast to undefined class not allowed.
dynamic_cast
, when casting to a class pointer, the class type
must be previously defined.
ERROR: Cannot find offset into non-class.
ERROR: Cannot find offset into undefined class.
ERROR: Invalid use of the scope operator.
::
can be used only in such expressions as
C3::mem
or
C1::C2::C3::mem
, where C1
is a class in which class C2
is declared, C3
is a class
declared in C2
, and mem
is a member of C3
.
ERROR: Cannot find the offset of 'object'.
char
, and its
number of bits may not comprise an integral number of chars
, a
bitfield in C++ has no size.
ERROR: Cannot find offset because class 'class-name' has no member named 'member-name'.
ERROR: Cannot take the size of an undefined class.
ERROR: Cannot dereference pointer to undefined class.
ERROR: No such constructor.
ERROR: 'identifier-value' previously declared as type-1. Cannot be defined as type-2.
union
specifier cannot be defined using
struct
or class
.
Similarly, a name declared as struct
or class
cannot be defined using union
.
ERROR: No such member 'member-name'.
ERROR: Member 'member-name' redeclared.
ERROR: 'identifier-value' not a definable member.
ERROR: 'this' may occur only in a (non-static) member function.
this
keyword outside the context of a non-static
member
function.
ERROR: Cannot create a new value of a function.
new
operator cannot be applied to a function type. Functions cannot be allocated by
means of the new
operator.
ERROR: Cannot create a new value of a reference.
new
operator cannot be applied to a reference type. Because a reference type is not an
object, a pointer to it could not be returned by operator new
.
ERROR: Cannot create a new instance of an undefined class.
new
operator can be applied
to it to create a new
instance of the class.
ERROR: Missing array size in expression.
ERROR: Class 'class-name' has no default constructor.
ERROR: Cannot initialize new array.
new
operator cannot be initialized by specifying an expression list.
WARNING: Delete applied to an object of an undefined class.
delete
operator was applied
to an object whose class has not been defined. If the class has a member delete
operator or a nontrivial destructor, then the object
or array will not be properly deallocated.
ERROR: Length expression of array must be integral.
ERROR: No match for call to function or overloaded operator.
ERROR: Missing constructor body.
ERROR: Non-virtual functions 'function-name' cannot be declared pure.
ERROR: Uninitialized const object.
const
object
or subobject must have an explicit initialization. Default initialization
can be used when the const
object is a class
or class array for a class with a user-defined default
constructor. See the C++ Standard, Section 8.5, paragraph 9.
ERROR: Uninitialized reference: reference.
ERROR: Const identifier or reference member 'member-name' must be initialized.
const
or reference member
must generally be initialized explicitly. This message is caused by a constructor
for a class with a const
or reference member
where the const
or reference member is not
initialized with a mem-initializer in the constructor. This message is generated
in some cases where a member contains a const
subobject. See the C++ Standard, Section 12.6.2, paragraph 4.
This is also output for aggregate initialization of a structure that does not initialize a reference member.
ERROR: Member 'member-name' must have initializer, class 'class-name' has no default constructor.
For example, if the type of X::a
is a class with a constructor
(but no default constructor) you receive this message if you omit the
a(10)
in the following code:
X::X() : a(10), b(11) { . . . }
ERROR: Base 'class-name' must have initializer, class 'class-name' has no default constructor.
For example, if b
is a base class of X
and is a
class with a constructor (but no default
constructor), you receive this message if you omit the
b(11)
in the following code:
X::X() : a(10), b(11) { . . . }
ERROR: Virtual base class 'class-name' must have initializer since class has no default constructor.
ERROR:'identifier-value' is not a direct base class or member of class 'class-name'.
ERROR: Member access through protected base class not allowed for 'member-name'.
ERROR: Member access through private base class not allowed for 'member-name'.
ERROR: Base access through protected base class not allowed.
Initializers for members of a class have the same access privileges as functions of that class. See the C++ Standard, Section 11.2.
ERROR: Base access through private base class not allowed.
ERROR: Cannot access protected member 'member-name' named in class 'class-name'.
Initializers for members of a class have the same access privileges as functions of that class. See the C++ Standard, Section 11.
ERROR: Cannot access private member 'member-name' named in class 'class-name'.
ERROR: Virtual function 'function-name' declared in virtual base 'class-name' must be overridden.
ERROR: Parameter of type 'void'.
void
.
ERROR: Default argument expression missing.
ERROR: Multiple declarations of function specifying default arguments.
ERROR: Arrays cannot contain elements of type 'void'.
void
.
ERROR: Arrays cannot contain bitfields.
ERROR: Arrays cannot contain functions.
ERROR: Functions cannot return functions.
ERROR: Functions cannot return arrays.
ERROR: Functions cannot return bitfields.
ERROR: Functions cannot return undefined classes.
ERROR: Pointers cannot point to references.
ERROR: Pointers cannot point to bitfields.
ERROR: References cannot refer to references.
ERROR: References cannot refer to bitfields.
ERROR: References cannot refer to objects of type 'void'.
void
objects, so there cannot be a reference to one.
ERROR: Member pointers cannot point to bitfields.
ERROR: Member pointers cannot point to references.
ERROR: Member pointers cannot point to objects of type 'void'.
void
objects, a pointer cannot point to one.
ERROR: Bitfields must be of integral type.
ERROR: Overloaded functions with indistinguishable arguments.
WARNING: K&R C style function definition.
strict
option.
ERROR: K&R C style functions cannot return classes with constructors or destructors.
ERROR: Conversion function must be a member function.
ERROR: Destructor function must be a member function.
ERROR: Conversion function 'function-name' not correctly declared.
ERROR: Destructor function 'destructor' not correctly declared.
void
).
ERROR: Copy constructor for a class may not take an argument whose type is that class.
class ABC
by declaring a copy constructor
of the form ABC::ABC(const ABC&
)
ERROR: Operator function 'function-name' must have operands of user defined type.
class
reference, enum
, or enum
reference type.
ERROR: Invalid linkage specifier.
extern
keyword must be
followed by a string literal specifying "C"
, "C++"
, or "OS"
. This error
may also be caused by an extra or misspelled token after an extern
keyword. "C"
, "C++"
, and
"OS"
must be specified
in uppercase.
ERROR: Linkage differs from prior declaration.
ERROR: Unknown linkage convention.
"C"
, "C++"
, and "OS"
linkage conventions.
Linkage to other languages must be specified using the SAS/C language keywords.
For more information on using other languages in combination with C, see
the SAS/C Compiler Interlanguage Communication Feature User's Guide.
ERROR: Missing class name.
ERROR: Repeated base class.
ERROR: Objects of abstract classes 'object-name' cannot be declared.
ERROR: Object of type 'void'.
void
.
ERROR: Static members 'member-name' of a local class may not be initialized.
static
data members of local classes are automatically initialized to zero.
ERROR: Cannot use undefined enum 'identifier-value'.
ERROR: Enum constants 'identifier-value' must be initialized with integral values.
ERROR: A class cannot be a member of itself.
ERROR: Cannot declare members of an undefined class.
ERROR: Cannot declare arrays of an undefined class.
ERROR: Cannot declare variables of an undefined class.
ERROR: Invalid member initializer.
const static
member with an integral type.
Other static
data members must be initialized
outside the class. Non-static
data members
must be initialized in the mem-initializer of each constructor function.
ERROR: Member function of a local class must be defined within that class: class-name.
ERROR: Member 'member-name' declared 'void'.
void
.
ERROR: 'friend' used on non-function.
friend
keyword has meaning only in function declarations inside a class.
ERROR:'friend' can only be used inside a class.
friend
keyword has meaning only in function declarations inside a class.
ERROR: Invalid syntax for access declaration.
friend
keyword
friend
keyword, remove the
type information, or remove the class name and scope operator, depending
upon which type of declaration you intended.
WARNING: Invalid access adjustment: 'member-name'.
using
declaration instead of an access declaration
to avoid this warning. This message is diagnosed with the strict
option.
WARNING: Access cannot be changed, but only reinstated.
using
declaration instead
of an access declaration to avoid this warning. This message is diagnosed
with the strict
option.
WARNING: Previously declared as a member in this class.
using
declaration instead of an access declaration to avoid this warning. This message
is diagnosed with the strict
option.
ERROR: 'class::member' is not a member of a base class.
ERROR: Access declaration names class that is not a base of this class.
ERROR: Constructor function 'constructor-name' not correctly declared.
void
), and the name of the constructor must be the same as the class
name.
ERROR: Destructor function 'destructor-name' not correctly declared.
void
).
Destructors may not be templates. The name of the destructor
must be a tilde (~) followed by the class name.
ERROR: Operator function 'function-name' has an incorrect number of arguments.
ERROR: Static functions 'function-name' cannot be virtual.
static
functions cannot be virtual. Remove the virtual
keyword from the
declaration of the static
function.
ERROR: Constructors 'constructor-name' cannot be virtual.
ERROR: Static functions 'function-name' cannot be used to override virtual functions.
static
member function was declared to have the same name and
argument types as a virtual function inherited from a base class. Use a
different name for the static
function.
ERROR: Linkage specification cannot be used in a member declaration 'member-name'.
ERROR: Cannot define classes or enums in return types or parameter lists.
ERROR: Invalid parameter name 'parameter-name'.
ERROR: Formal 'argument-name' is not listed in function declaration.
ERROR: Initialized local extern 'variable'.
ERROR: A typedef name ('name') cannot be initialized.
typedef
names cannot contain initializers.
ERROR: Class with constructors must have an initializer.
ERROR: Cannot define classes or enums in type names.
new
operators, sizeof
expressions, or offsetof
expressions.
ERROR: Not a function.
ERROR: A mem-initializer may be used only within constructor functions.
ERROR: Base or member 'identifier-value' re-initialized.
a(10)
part appears twice:
X::X() : a(10), a(10) { . . . }
ERROR: Old style base initializer cannot be used on class with no bases.
X
has no base classes, the following code tries to
initialize a non-existent base and generates this message:
X:: X() : (10) { . . . }To correct the error, delete the
(10)
part.
ERROR: Old style base initializer cannot be used on class with multiple base classes.
X
has more than one base, the
following code is ambiguous and generates this message:
X::X() : (10) { . . . }To correct the error, insert the name of a specific base class before the
(10)
.
WARNING: Statement is unreachable.
ERROR:'case' label must be within a switch statement.
case
label is not allowed outside of a switch
statement.
ERROR: 'default' label must be within a switch statement.
default
label is not allowed outside of a switch
statement.
ERROR: 'continue' must be within a loop ('do', 'for', or 'while') statement.
continue
statement is not allowed outside of a loop statement.
ERROR: 'break' must be within a switch or loop ('do', 'for', or 'while') statement.
break
statement is valid only within switch
or loop
statements.
ERROR: Missing return value.
ERROR: Return value given for constructor, destructor, or void function.
void
function. However, a void expression
is allowed for a return statement in a void
function.
ERROR: Missing function name in function declaration.
ERROR: Illegal formal declaration list in prototype function definition.
ERROR: Formal 'argument-name' must be declared in function header identifier list.
ERROR: Expression in array declarator must be a constant expression.
ERROR: Expression in array declarator must be integral.
ERROR: Expression in array declarator must be positive.
ERROR: Map directive does not match prior directive.
ERROR: Invalid bitfield size.
ERROR: Cannot use undefined class 'class-name' as base class.
ERROR: Missing declaration-specifier.
ERROR: Illegal use of 'item' in local member function.
static
variables,
extern
variables and
functions, and enumeration constants only from the enclosing scope.
ERROR: A class cannot be derived from a union 'union-name'.
ERROR: A union 'union-name' cannot be derived from another class.
ERROR: Constant expression contains a division by zero (0).
ERROR: Cannot take the size of a function.
ERROR: Cannot take the size of a bitfield.
ERROR: Cannot take the size of void.
void
objects, you cannot take the size of one.
ERROR: Cannot take the size of array with unspecified length.
WARNING: Cannot jump into a block to a label after a declaration having an initializer.
ERROR: Cannot jump into a block to a label after a declaration having an initializer.
ERROR: Overloaded member functions 'function-name' may not be both static
and non-static.
static
or non-static
.
ERROR: Function hides a virtual function from base class.
ERROR: Overriding virtual function 'function-name' has different return type.
ERROR: Arrays cannot contain references.
ERROR: Previous declaration of function had different return type.
ERROR: Cannot have two extern "C" functions with same name 'name'.
extern "C"
.
ERROR: Previous declaration differed in the use of __builtin.
__builtin
keyword.
All must have it, or none must have it.
ERROR: object-type 'expression' cannot be used in default argument expressions.
-static
members, formal parameters, and automatic variables
cannot be used in
default argument expressions.
ERROR: Ambiguous use of keyword.
ERROR: Keyword can only be used on functions.
virtual
and
inline
can
be used only in function declarations.
WARNING: 'keyword' cannot be applied to object-type.
ERROR: 'keyword' cannot be applied to object-type.
auto
to the definition of a class (although auto
can be applied
to the definition of an object whose type is that class). Depending
upon the combination of keywords in question, this may be treated as a
warning or an error.
ERROR: Previous declaration was not static.
-static
and later declared static
.
ERROR: Function declared 'inline' after first use.
ERROR: Prototypes can only be specified for C, C++, and __asm functions.
ERROR: Only C, C++, and __asm functions can be overloaded.
ERROR: Member functions must be C++ functions.
ERROR: Keyword can only be used on function pointers.
__local
and __remote
can be used only
on function pointers.
ERROR: A declaration must declare something.
ERROR: function-name cannot have 'storage-type' storage class.
const
or volatile
cannot also be declared static
.
WARNING: Extra comma at end of enumeration list.
WARNING: Enum value: value is used for both 'enum-1' and 'enum-2'.
enum
constants in the same enumeration type have the same value. This
may be what you intended; the warning is given in case it is not
intended.
ERROR: Cannot overload 'main' or '_dynamn'.
main
nor _dynamn
can be overloaded.
ERROR: Cannot call or take the address of 'main'.
main
cannot be called, nor can its address be taken.
ERROR: 'main' cannot be 'storage-type'.
static
or inline
.
ERROR: Anonymous classes cannot have constructors or destructors.
ERROR: Destructor names 'destructor-name' must be the same as their class names 'class-name'.
ERROR: Expression in array declarator must not be negative.
ERROR: Cannot allocate array of class 'class-name' with no default constructor.
new
operator, the class must have a default
constructor.
ERROR: Invalid constructor given for member 'member-name'.
ERROR: 'operand-1' and 'operand-2' are not compatible types for conditional operator.
ERROR: type-1 operator type-2: Invalid type for binary operator.
ERROR: 'operand' is of invalid type for postfix operator 'operator'.
++
or --
) cannot be applied to an object
of the given type.
WARNING:'operator' is invalid for operand type 'operand'.
ERROR:'operator' is invalid for operand type 'operand'.
ERROR:'object' is of invalid type for call operator.
()
) cannot be applied to an object of the given type.
ERROR: Invalid pointer conversion from 'type-1' to 'type-2'.
ERROR: Cannot take size of pointer to overloaded function 'function-name'.
sizeof
cannot be applied to such a pointer.
WARNING: Address of temporary taken by casting to reference, (reference).
ERROR: Error writing to output file: file-name.
stderr
may contain library messages with additional
information about the error.
ERROR: Inline member function does not end.
ERROR: Static function 'function-name' was not defined.
static
but has not been defined in this source file.
ERROR: Global anonymous unions must be static.
static
.
ERROR: Anonymous unions may only have nonstatic data members.
union
, struct
,
or class
.
ERROR: Anonymous unions may not have private or protected members.
union
, struct
, or class
.
ERROR:'identifier-value' redeclared in anonymous union.
ERROR: An anonymous union cannot be declared as a static member.
ERROR: Cannot load special character table 'table-name'.
ERROR: Conflicting declaration of name 'identifier-value' reserved for purpose.
ERROR: Cannot initialize a function 'function-name'.
ERROR: Static members member-name cannot be initialized by a mem-initializer.
Static
members should be initialized by the definition of the static
member outside the class. For example, this message is issued if you use
the following code and a is a static
member:
X::X() : a(10) { . . . }
ERROR: Enum constants identifier-value cannot be initialized by a mem-initializer.
Enum
constants should be initialized inside the enum
declaration, as they are in C. For
example, this message is issued if a
is an enumeration constant:
X::X() : a(10) { . . . }
ERROR: Types must match in a destructor expression: object-type destructor-type
->
) of the left operand of the .
or ->
expression. This message is also output for
class destructors when the destructor is specified as an unqualified
name (for example, "object.type_name"
) and the specified
type does not match the object type.
ERROR: Cannot create a new value of a void.
new
operator cannot be applied to void
. Because
void
is not an object type, a
pointer to it could not be returned by operator new
.
ERROR: Loop in -> operators.
ERROR: A linkage-specification may occur only in namespace scopes.
ERROR: Cannot define a type in return or argument types.
struct
tag) cannot be defined in
an argument list or in the
specification of the return type.
ERROR, WARNING: object may not have the same name as its class.
ERROR: Overloaded operator 'operator' cannot have default arguments.
operator()
and
the new
and delete
operators, it is illegal to declare overloaded operators with default arguments.
For example,
int operator +(int=3,int=4)
is not a valid declaration.
See the C++ Standard, Section 13.5.
ERROR: Invalid use of abstract class: class-name.
ERROR: An object of a class with a object-type may not be a member of a union.
ERROR: Error declaring 'new': explanation.
new
function must have
a return type of void*
. Its first argument
is required and must be of type size_t
.
ERROR: Initializer-clause cannot be used for class having an object-type.
={10,2,10.2}
).
See the C++ Standard, Section 8.5.1.
ERROR: Conversion to a virtual base class 'class-name' from a derived class is not allowed for member pointers.
ERROR: Cannot return attempted-return-type from function returning declared-return-type.
ERROR: Function 'function-name' has an initializer.
ERROR: Character array array-name too short for string of length string-length.
ERROR: Too many initializers for array-name: found number initializers.
ERROR: Too many initializers for class-name.
ERROR: Left operand of 'operator' must be type.
ERROR: Type 'type' is invalid for the left operand of 'operator'.
ERROR: Case label value must be a constant expression.
case
label.
ERROR: Duplicate case label value.
case
label occurs more than once within a switch
statement.
ERROR: More than one default.
default
label in a single switch
statement.
ERROR: symbol-name is not an enum.
enum
keyword,
but is not an enumeration.
ERROR:symbol-name is not a class, struct, or union.
class
, struct
,
or union
keyword, but is not a class
, struct
,
or union
.
WARNING: Wide and narrow character strings concatenated, using width.
L"abc"
;
narrow characters strings are the usual
"abc"
. These two types of strings should not be
concatenated together. For example,
neither of the following statements are valid:
"abc" L"def" L"abc" "def"If the first string in the concatenation is wide, the translator treats the result as a wide string. Similarly, if the first string is narrow, the translator treats the result as narrow.
WARNING: Missing return statement.
return
statement is missing
at the end of the outer block of a function and a return value is required.
Within a function try
block for a function
with a return value, a return statement is missing at the end of the main
body or in one of the handlers for the function try
block.
WARNING: Zero-length array declared.
classes
, structs
, and unions
)as an
extension of standard C and C++. This message
is diagnosed with the strict
option.
ERROR: Floating point value out of range.
WARNING: data-type-1 initialized with data-type-2.
int
has been used to
initialize a char
.
WARNING: data-type-1 assigned to data-type-2.
long
has been assigned to a short
.
WARNING: sign-type-1 data-type-1 assigned to sign-type-2 data-type-2.
ERROR: sign-type-1 data-type-1 assigned to sign-type-2 data-type-2.
long
has been assigned to an unsigned long
),
or conversely, an unsigned data type has been assigned to a signed data
type of the same size (for example, an unsigned int
has been assigned to
an int
). If the assigned value is a constant that cannot be represented
correctly by the type to which it is assigned, an error results.
Otherwise, the message is a warning.
ERROR: A function definition name requires an explicit parameter list.
typedef int F(int); F foo { return 10; }
WARNING: Implicit conversion of member function name to a member pointer.
WARNING: Symbol name was not used.
WARNING: Variable name used before being initialized.
WARNING: Symbol symbol was initialized but never referenced.
ERROR: name must be a function, not a type.
The ellipsis ('...') may not be used in an overloaded operator except operator new
,
operator new[]
, operator delete
, operator delete[]
,
and operator()
.
operator new
and operator
new[]
must be functions returning a void pointer. The first
argument must be a size_t
.
operator delete
and operator
delete[]
must be functions returning void. The first argument
must be a void pointer.
ERROR: data-type may not use ('...').
ERROR: name must return a type-1 not a type-2.
ERROR: 'operator new's first argument must be a 'size_t'. ERROR: 'operator new[]'s first argument must be a 'size_t'.
ERROR: 'operator delete's first argument must be a 'size_t'. ERROR: 'operator delete[]'s first argument must be a 'size_t'.
ERROR: Previous declaration of name was attribute-1, this declaration is attribute-2.
Note:
For some attributes, C++ will apply a default if the attribute
is not explicitly specified in the declaration. A declaration with
a specific keyword may conflict with a previous declaration with no
keyword, depending on the current defaults. Which defaults are applied
by C++ depend upon the specific attribute and the user supplied options.
For example, if a previous declaration specified __rent
, the
current declaration for the same symbol cannot specify __norent
.
Declarations must be consistent.
ERROR: Previous declaration of name differed in the use of attribute-name.
Note that for some attributes, C++ will apply a default if the attribute was not explicitly specified in the declaration. So a declaration with a specific keyword may conflict with a previous declaration with no keyword depending on the current defaults. Which defaults are applied by C++ depend upon the specific attribute and the user supplied options. The declarations should be made consistent.
ERROR: Default argument(s) of function used before they are defined.
ERROR: Invalid use of K&R C style declaration for name.
ERROR: Bitfields cannot be static members.
struct
, and make the struct a static member.
ERROR: Missing template argument list for 'template-name'.
ERROR: Invalid template argument.
ERROR: Not enough arguments for template.
ERROR: Too many arguments for template.
ERROR: Cannot instantiate incomplete template class 'template-class'.
ERROR: Recursive template instantiation of 'template-class'.
ERROR: Template actual parameters cannot depend on unnamed or local types.
ERROR: Template instantiation failed for 'template-name'.
WARNING: Template function not deducible.
strict
option.
ERROR: Template declaration has a nested class definition.
template <class T> class C { . . . } * func( T* ); // Error
ERROR: Scope for 'name' does not match a class template.
template <class T, class U> class C { class Nested { ... }; ... }; template <class X, class Y> int C<X, Y>::i = 1; // OK template <class X, class Y> int C<X, Y>::Nested::i = 1; // OK template <class X, class Y> int C<Y, X>::j = 0; // Error template <class X, class Y> int C<Y, int>::k = 7; // ErrorIn other words, the template parameters in effect must match the parameters from the template class declaration and the argument list for the template scope must use the template parameters in the original order.
ERROR: Template class member declaration must define the member.
WARNING: Statement has no effect.
ERROR: Unrecognized template declaration.
ERROR: Template argument list does not match formals.
ERROR: Multiple definitions for 'symbol'.
ERROR: Template actual 'object' does not have external linkage.
ERROR: Ambiguous template declarations for 'function-signature'.
ERROR: Type members (name) cannot be initialized by a mem-initializer.
class
, enum
, or typedef
name)
whose type is not a base class of
the class being constructed.
ERROR: Invalid scoped declaration in member list.
ERROR: Illegal bitfield declaration.
typedef
may not be used with
a bitfield declaration. Also field types may not be long long
or
unsigned long long
.
ERROR: Templates may not be declared in local scopes.
ERROR: Invalid explicit template specialization.
template <>
) must refer to a specialization of a previously
declared template function, template class, or static member of a
template class.
ERROR: Template function was explicitly specialized after its first use.
WARNING: Old-style template specialization.
template
<>
.
ERROR: Template class was specialized after it was implicitly instantiated.
ERROR: Invalid explicit template instantiation.
template
but has no following template formal list)
must specify a specialization of a previously declared template
function, template class, or static member of a template class.
ERROR: No template definition for 'template-name'.
ERROR: Template instantiations are too deeply nested (>max-levels levels).
template <class X> class C { C<X*> c; }; C<int> x; // requires C<int>, C<int*>, C<int**>, C<int***>, ...
ERROR: Template item was both explicitly instantiated and specialized.
ERROR: Explicit instantiation of a compiler generated function.
ERROR: Static data member of a template was specialized after it was used.
WARNING: Keyword 'keyword' is not legal in function declaration.
extern
.
ERROR: Invalid scoped declaration.
ERROR: Explicit template arguments may not be specified here.
f <int>
)
was used in a declaration where it is not valid. Explicit template argument
lists may be used for explicit specialization and instantiation declarations,
as well as friend function declarations.
ERROR: Unexpected initializer in an explicit template instantiation declaration.
ERROR: Elaborated name depends on a template parameter.
template <class T> void f( class T* ); // Error
ERROR: A template declaration may declare only one item.
template <class T> void f( T* ), g( T* ); // Error
ERROR: Unnamed class definition in a template declaration.
template <class T> class { . . . }; // Error
ERROR: Template formal parameters cannot be type-constraint
void
, or have class type. A template data formal parameter
has an invalid type.
ERROR: Instantiation of 'name' has type (type) but type was expected.
name
has type
, but a
class type was expected.
A template declaration, when specialized, used a template formal dependent name in a context where a class name was expected, but the specialized type was not a class. For example:
template <class T> void f( int T::* p ); void testit() { f<int>( 0 ); // Error }
ERROR: Instantiated name 'name' does not resolve to [type | scope].
name
does not resolve to a type or scope name.
A template declaration, when specialized, used a template formal dependent name in a context where a scope or type name was expected, but the specialized type was not a class type. For example:
template <class T> class C { public: int Z; }; template <class U> void f( typename C<U>::Z* p ); void testit() { f<int>( 0 ); // Error, C<int>::Z is not a type }
ERROR: Incomplete template member initializer. Found unexpected 'token'.
For example:
template <class T> struct C { static int si; }; template <class T> int C<T>::si = ( 5 ; // unexpected ';' due to missing ')'The C++ translator can sometimes be confused by commas in nested template argument lists in the initializer. Enclosing the initializer in parentheses avoids this limitation:
template <class T> int C<T>::si = ( otherTemplate< T, T>().memFunc() );
ERROR: Template function specialization does not correspond to any template declarations.
WARNING: Missing elaborator on a friend class declaration.
ERROR: Template member declaration does not match the member 'member-name'.
ERROR: Default arguments are not allowed on template redeclaration 'template-name'.
WARNING: Dubious type specifier 'type-name'. Use 'typename'.
ERROR: Missing return type specifier.
int
rule of C is considered obsolete.
NOTE: Suggested explicit template instantiation declaration: information
showinst
option.
ERROR: A condition cannot specify a function or an array.
ERROR: A condition cannot declare a new class or enumeration.
ERROR: No such conversion-specification conversion; to ( type-1 ) from ( type-2 ).
static_cast
to try to convert a pointer to an
integral type.
ERROR: Invalid qualifier change; to ( qualifier-1 ) from ( qualifier-2 ).
const_cast<>
to perform the needed qualifier conversion.
ERROR: Cannot apply typeid operator to an undefined class.
ERROR: Cannot apply typeid operator to an overloaded function name.
WARNING: Polymorphic type information may not be available.
typeid
or dynamic_cast
was applied to a polymorphic
type, but the rtti
translator option was not specified.
ERROR: Header <typeinfo> must be included before using typeid.
<typeinfo>
header must be included at global scope before the
first use of the typeid
operator in order to declare the
type_info
class.
ERROR: Dynamic_cast from undefined class pointer not allowed.
ERROR: Polymorphic class object required.
dynamic_cast
to convert to a void pointer type, the
source type must be a pointer to a polymorphic class type. (A
polymorphic class is one that has virtual function members.) When
using dynamic_cast
to convert to a class pointer type, the source
type must be a pointer to the same class, a pointer to a derived
class of the target class, or a pointer to a polymorphic class.
When using dynamic_cast
to convert to a class reference, the source
type must be of the same class, a derived class of the target class,
or a polymorphic class.
ERROR: Invalid use of type member member-name.
.
or ->
operator must be a data or function member.
WARNING: Implicit template instantiation uses static or unnamed namespace object 'object-name'
WARNING: Static or unnamed namespace use forces automatic template instantiation in primary module.
WARNING: Inline function 'function-name' uses static or unnamed namespace object 'object-name'
ERROR: Inline function function-name was used but not defined.
ERROR: A condition initializer must be an expression.
Ambiguous result for conditional expression.
To avoid this problem, use static_cast
to be explicit
about the intended conversion.
Invalid use of non-static member function.
This error could indicate a missing call argument list or an incorrectly specified member pointer constant.
Ambiguous use of overloaded function name '<function-name>'.
static_cast
.
ERROR: Operator function 'function-name' may not be a static member.
operator new
, operator new[]
, operator delete
,
and operator delete[]
, member operator functions
must be non-static.
ERROR: Operator function 'function-name' must be a class member.
operator=
, operator->
, operator[]
, and
operator()
may only be declared as class members.
ERROR: Multiple declarations of a default template argument.
ERROR: Missing default argument for a template parameter.
ERROR: Default template arguments allowed only for class templates.
ERROR: Default template argument does not match formal.
WARNING: Obsolete specification of array length in a 'delete[]' expression.
delete[]
expression. This is an obsolete
C++ feature and will not be supported in the future. The expression is ignored.
This warning can be resolved by removing the expression inside the square brackets.
ERROR: Function 'function-name' in unnamed namespace used but not defined.
ERROR: Object 'object-name' was used and requires a definition in this translation unit.
ERROR: Scoped declaration must occur in scope-type.
Except for friend declarations, explicit specializations, and explicit instantiations, a declaration with a qualified ID declarator for a namespace scoped variable, function, function template, class member, or class template member must be a definition in an enclosing namespace scope of the original declaration of the item or template.
Except for friend declarations, explicit specializations, and explicit instantiations, a definition of a nonlocal class using a qualified ID in the class header must be in an enclosing namespace scope of the original declaration of the class.
A definition of a local, nested class using a qualified ID in the class header must be in the same block scope as the definition of the containing class.
WARNING: Qualified declarator names an enclosing namespace 'name'
ERROR: Explicit specialization may not be declared here.
ERROR: Explicit instantiation may not be declared here.
ERROR: 'declaration-name' not previously declared.
ERROR: Must be a definition.
ERROR: Cannot bind reference to a bitfield lvalue.
const
reference
allows a temporary to be introduced to hold the bitfield value.
ERROR: Copy assignment for the class 'class-name' cannot be implicitly defined.
const
or reference non-static data members,
which makes it impossible to implicitly define the operator.
ERROR: Not a namespace name.
using
directive did not resolve to a namespace.
ERROR: A using declaration may not specify a template id.
ERROR: A using declaration must specify a qualified id.
ERROR: Must be a namespace member.
using
declarations in function
and namespace scopes must specify a namespace member name.
ERROR: Must be a base class member.
using
declarations in class
scopes must specify a base class member name.
ERROR: Overloaded using declaration.
using
declaration for a
function has been overloaded by a regular declaration with the same name and
parameter types. This is not allowed except in class scopes.
ERROR: 'member-1' was previously declared with 'member-2' access.
ERROR: 'object-name' was previously declared as a different object.
using
declaration.
One of the declarations must be removed or renamed.
ERROR: 'member-name' was declared by a using declaration.
using
declaration. Such a member may
not be specified in a qualified declarator. Declare it instead with the original
scope of the object or function to which the using
declaration refers.
ERROR: 'function-name' is not a function template name.
ERROR: Member must be visible in a direct base class.
using
declaration or access declaration for a class member
must be visible in a direct base class of the class containing the using declaration.
ERROR, WARNING: Using declaration refers to an ambiguous base class member 'member-name'.
using
declaration refers
to a member of a base class that is an ambiguous base of the class containing
the using declaration. A reference to the member via the using
declaration will be ambiguous.
ERROR: Member templates may not be virtual.
virtual
keyword.
ERROR: Invalid pure specifier.
ERROR: The 'template' keyword was used with a non-template name 'template-name'.
template
keyword and a name was encountered; however, when
resolved, the name was not a template.
ERROR: Found unexpected type name 'type-name'. Use the 'typename' keyword.
typename
keyword is required to identify template formal dependent names that refer
to types.
ERROR: The 'typename' keyword was applied to an unqualified id 'type-name'.
typename
keyword must have a scope qualifier.
ERROR: 'template-name' is not a class template name.
ERROR: A friend declaration may not define a class
class C { class N; friend class N; // N was forward declared to refer to C::N class N { ... }; ... };
WARNING: Possible misuse of Boolean with composite operator.
+=
) is being used to update a target lvalue with bool
type. The result is
computed by converting to the common
arithmetic type, performing the arithmetic operation, and then converting
back to bool
. This may not produce the expected
result.
ERROR: Cannot throw void or an undefined class or class pointer.
ERROR: The catch(...) handler must be the final handler.
ERROR: Cannot jump into try block or handler.
goto
or switch
) into the middle of the initial subblock of a try block
or into a catch handler subblock from outside the subblock are not allowed.
These subblocks have exception handling tasks that are incompatible with
such transfers of control.
ERROR: Exception specification for 'function-name' does not match previous declaration.
ERROR: Exception specification type may not be void or an undefined class, class reference, or class pointer.
ERROR: Exception specifications may only appear in a non-typedef declaration or definition.
ERROR: Exception specification for overriding virtual function 'function-name' includes types not allowed by the overridden function 'function-name'.
struct B {...}; struct D : public B {...}; struct S { virtual void e(); // propagates all exceptions virtual void f() throw(); // propagates no exceptions virtual void g() throw( int ); // propagates int exceptions virtual void h() throw( int ); // propagates int exceptions virtual void x() throw( B ); // propagates B exceptions }; struct T : public S { void e(); // OK, all exceptions allowed by S::e() void f() throw(int); // error, int not allowed by S::f void g() throw(); // OK, no exceptions propagated void h(); // error, S::h() only allows int void x() throw( D ); // OK, S::h() allows public base B };
A type is allowed in the exception specification of an overriding function if the same type is in the exception specification for the overridden function. Also, a class type is allowed in the exception specification of an overriding function if an unambiguous public base of the class is in the exception specification for the overridden function. Similarly, a class pointer type is allowed in the exception specification of an overriding function if a pointer to an unambiguous public base of the class is in the exception specification for the overriden function.
ERROR: Exception specification mismatch for assignment or initialization.
ERROR: Empty list initializer used for array with missing size.
int a[] = {};
was encountered.
Normally, a missing array size can be
determined by using the number of elements in the initializer list. However,
arrays of size zero are not generally allowed.
WARNING: Missing or ambiguous placement delete operator 'operator-name'.
new
expression with placement
arguments was encountered and there were either zero or multiple corresponding
placement delete
operators found for handling
cleanup in cases where the new object initialization throws an exception.
This message indicates a potential memory leak. Note that the operator delete
name is looked up by the same method used
for delete
expressions, so the name may be
found in a different scope than the operator new
name. This message is diagnosed with the strict
option.
ERROR: Illegal return statement in function try block handler for a constructor.
WARNING | ERROR: Constant value out of range.
long
or unsigned long
.
A warning is generated when initializing or
assigning a integral constant to an arithmetic type that cannot represent
the constant value. The warnings can be eliminated by correcting the constant
value or using an explicit cast.
ERROR: Exception handling not enabled.
except
option was not specified.
Turn on the except
option to support exception
handling.
ERROR: Previously initialized in the class body.
struct S { static const int one = 1; static const int two = 2; }; const int S::one = 1; // error const int S::two; // OK, initialized to 2
WARNING: Multiple assignments to the same lvalue between sequence points.
This is currently only detected when the result of an assignment, prefix increment, or prefix decrement operator is used as the lvalue operand of an assignment, increment, or decrement operator.
'identifier-value' previously declared as external to be a type-name.
extern
in a function block.
WARNING: Type of external function-ID uses an unnamed or local class or enum. Type of external function-ID uses...
ERROR: Type of external function-ID uses an unnamed or local class or enum. Type of external function-ID uses...
enum
or a class
or enum
declared locally inside a function.
The function or object cannot be referred to from other compilation units
because the type is not available. If the type is correct and the item is
not a class member, the item can be declared with internal linkage using the static
keyword. For class members, if the class has external
linkage, the types being used for member declarations must have names.
This is currently an error only when local types are used.
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.