IntroductionStudents of of the Open University course T223 will find additional information on this page on some of the 'C' Error messages, that is in addition to, or may differ from the information in their 'C' T223 Reference Manual. Some of the words are linked. Underlined words in black are still to be linked. TIPS.
Compiler Error MessagesArray bounds missing ] - Compiler errorYour source file declared an array in which the bounds were not terminated by a right bracket.
Array size too largeArrayAssembler statement format directive,directive syntax,The declared arra y is too large for the available memory.Assembler statement too longInline assembly statements can't be longer than 480 bytes.Bad file name format in include directiveInclude and line directive file names must be surrounded by quotes ("filename.h") or angle brackets ().The file name was missing the opening quote or angle bracket. If a macro was used, the resulting expansion text is not surrounded by quote marks. Bad ifdef directive syntaxAn #ifdef directive must contain a single identifier (and nothing else) as the body of the directive.Bad undef directive syntaxAn #undef directive must contain a single identifier (and nothing else) as the body of the directive.Bit field too largeThis error occurs when you supply a bit field with more than 16 bits.Call of nonfunctionThe name being called is not declared as a function.This is commonly caused by incorrectly declaring the function or misspelling the function name. Cannot modify a const objectThis indicates a not allowed operation on an object declared to be const, such as an assignment to the object.Case outside of switchThe compiler encountered a case statement outside a switch statement.This is often caused by mismatched braces. Case statement missing :A case statement must have a constant expression followed by a colon.The expression in the case statement either was missing a colon or had an extra symbol before the colon. Character constant must be one or two characters longThese constants can only be one or two chrs s long.Compound statement missing ;The compiler encountered an expression statement without a semicolon following it.Conflicting type modifiersThis occurs when a declaration is given that includes more than one addressing modifier on a pointer or more than one language modifier for a function.Only one addressing modifier (_ _far16,) can be given for a single pointer. Only one language modifier (cdecl, and pascal) can be given for a function. One cannot multiply derive from a class declared to use the fast this pointer optimization, and one that was not. For example: class __fastthis A { // one way to declare a class as using the myex(); // fast this optimization, note that }; // #pragma option -po- turns it off. class B { twoex(); }; class c : A , B {}; // error // note that __fastthis is only recognized in BC 4.0 or later |
Constant expression requiredArrays must be declared with constant size.This error is commonly caused by misspelling a #define constant. Could not find file 'filename'The compiler is unable to find the file supplied on the command line.Remidy Check if the file exists before trying to use file Declaration missing ;Your source file contained a struct or union field declaration that was not followed by a semicolon.Check previous lines for a missing semicolon. Declaration syntax errorYour source file contained a declaration that was missing a symbol or had an extra symbol added to it.Check for
Practical Example in Exercise in Tutorial 2 Default outside of switchThe compiler encountered a default statement outside a switch statement.This is most commonly caused by mismatched braces. Define directive needs an identifierThe first non-whitespace chr. after a #define must be an identifier. The compiler found some other chr.See Also Identifier expected Division by zeroA divide or remainder expression had a literal zero as a divisor. Example of avoiding this error Tut. 6 do statement must have whileYour source file contained a do statement that was missing the closing while keyword.do-while statement missing (In a do, for, if, switch, or while statement, the compiler found no left parenthesis after the while keyword or test expression.
do-while statement missing (In a do, for, if, switch, or while statement, the compiler found no left parenthesis after the while keyword or test expression.do-while statement missing OR For statement missing ;In a do or for statement, the compiler found no semicolon after the right parenthesis.Duplicate caseEach case of a switch statement must have a unique constant expression value.Enum syntax errorAn enum declaration did not contain a properly formed list of identifiers.Error directive: 'message'This message is issued when an #error directive is processed in the source file. 'message' is the text of the #error directive.Error writing output fileA DOS error that prevents the C++ IDE from writing an .OBJ, .EXE, or temporary file.Solutions Make sure that the Output directory in the Directories dialog box is a valid directory. Check that there is enough free disk space. Delete unneeded files and try again. Possible faulty disk Expression syntaxThis is a catch-all error message when the compiler parses an expression and encounters a serious error.Possible CausesThis is most commonly caused by one of the following: two consecutive operators mismatched or missing parentheses a missing semicolon on the previous statement.Solutions If the line where the error occurred looks syntactically correct, look at the line directly above for errors. Try moving the line with the error to a different location in the file and recompiling. If the error still occurs at the moved statement, the syn tax error is occurring somewhere in that statement. If the error occurred in another statement, the syn tax error is probably in the surrounding code. Extra parameter in callA call to a function, via a pointer defined with a prototype, had too many arguments.Extra parameter in call to functionA call to the named function (which was defined with a prototype) had too many arguments given in the call.File name too longThe file name given in an #include directive was too long for the compiler to process. File names in DOS must be no more than 79 chrs long.In older compilers the MSDOS restiction may apply for statement missing (In a for statement, the compiler found no left parenthesis after the while keyword or test expression.for statement missing )In a for statement, the compiler found no right parenthesis after the while keyword or test expression.for statement missing ;In a forstatement, the compiler found no semicolon after the right parenthesis.Function call missing ) - Compiler ErrorThe function call argument list had some sort of syn tax error, such as a missing or mismatched right parenthesis.Goto statement missing labelThe goto keyword must be followed by an identifier.See Also Identifier expected Identifier expectedAn identifier was expected here, but not found.In C, an identifier is expected in the following situations:
if statement missing (In a if statement, the compiler found no left parenthesis after the if keyword or test expression.if statement missing )In a if statement, the compiler found no right parenthesis after the if keyword or test expression.Illegal character 'character' ('value')The compiler encountered some invalid chr. in the input file.The hexadecimal value of the offending chr. is printed. This can also be caused by extra parameters passed to a function macro. Illegal initializationInitializations must be one of the following:
Illegal octal digitThe compiler found an octal constant containing a non-octal digit (8 or 9).Illegal parameter to _ _emit_ _There are some restrictions on inserting literal values directly into your code with the __emit__ function.For example, you cannot give a local variable as a parameter to __emit__. Illegal pointer subtractionThis is caused by attempting to subtract a pointer from a non-pointer.Illegal structure operationStructures can only be used with dot (.), address-of (&) or assignment (=) operators, or be passed to or from a function as parameters.The compiler encountered a structure being used with some other operator. Illegal use of floating pointFloating-point operands are not allowed in these operators
Illegal use of pointerPointers can only be used with these operators:
Example int main (void) { char *p; p /= 7; /* ERROR: not allowed Use of Pointer */ return 0; } Improper use of typedef 'identifier'Your source file used a typedef symbol where a variable should appear in an expression.Check for the declaration of the symbol and possible misspellings. Inline assembly not allowedYour source file contains inline assembly language statements and you are compiling it from within the integrated environment.You must use the BCC command to compile this source file from the DOS command line. Incompatible type conversionThe cast requested can't be doneIncorrect number formatThe compiler encountered a decimal point in a hexadecimal number.Incorrect use of defaultThe compiler found no colon after the default keyword.Invalid indirectionThe indirection operator (*) requires a non-void pointer as the operand.Example int main (void) { void *p; *p = 10; /* ERROR: Invalid Indirection */ return 0; } Invalid macro argument separatorIn a macro definition, arguments must be separated by commas.The compiler encountered some other chr. after an argument name. This is correct: #define tri_add(a, b, c) ((a) + (b) + (c)) This is incorrect: #define tri_add(a b. c) ((a) + (b) + (c)) Invalid pointer additionYour source file attempted to add two pointers together.Invalid use of dotAn identifier must immediately follow a period operator (.).Example struct foo { int x; int y; } p = 0,0; int main (void) { p.x++; /* Correct */ p. y++; /* Error: Invalid use of dot */ return 0; } Lvalue requiredThe left side of an assignment operator must be an addressable expression.Addressable expressions include the following:
Macro argument syntax errorAn argument in a macro definition must be an identifier.The compiler encountered some non-identifier chr. where an argument was expected. See Also Identifier expected Macro expansion too longA macro can't expand to more than 4,096 chrs. s.Misplaced breakThe compiler encountered a break statement outside a switch or looping construct.You can only use break statements inside of switch statements or loops. Misplaced continueThe compiler encountered a continue statement outside a looping construct.Misplaced decimal pointThe compiler encountered a decimal point in a floating-point constant as part of the exponent.Misplaced elif directiveThe compiler encountered an #elif directive without any matching #if, #ifdef, or #ifndef directive.Misplaced elseThe compiler encountered an else statement without a matching if statement.Possible Causes
Misplaced else directiveThe compiler encountered an #else directive without any matching #if, #ifdef, or #ifndef directive.Misplaced endif directiveThe compiler encountered an #endif directive without any matching #if, #ifdef, or #ifndef directive.Must take address of a memory locationYour source file used the address-of operator (&) with an expression that can't be used that way; for example, a register variable.No file name endingThe file name in an #include statement was missing the correct closing quote or angle bracket.Non-portable pointer comparison(Command-line equivalent for controling display of this warning=-wcpt)Your source file compared a pointer to a non-pointer other than the constant 0. You should use a cast to suppress this warning if the comparison is proper. Default=displayed Non-portable pointer conversion(Command-line for controling display=-wrpt)An implicit conversion between a pointer and an integral type is required, but the types are not the same size. This can't be done without an explicit cast. This conversion might not make any sense, so be sure this is what you want to do. Not an allowed typeYour source file declared some sort of forbidden type; for example, a function returning a function or arra yNumeric constant too large/*Bordland */String and chr. escape sequences larger than hexadecimal or octal 77 can't be generated. Two-byte chr. constants can be specified by using a second backslash. For example, // represents a two-byte constant. A numeric literal following an escape sequence should be broken up like this: printf("" "12345"); This prints a carriage return followed by 12345. /*T223 */ String and chr. escape sequences larger than hexadecimal /xFF or octal /77 can't be generated. Two-byte chr. constants can be specified by using a second backslash. For example, /0D/x0A represents a two-byte constant. A numeric literal following an escape sequence should be broken up like this: following an escape sequence should be broken up like this: printf("/x0D" "12345"); This prints a carriage return followed by 12345. Out of memoryThe total working storage is exhausted.This error can occur in the following circumstances:
Pointer to structure required on left side of -> or ->*Nothing but a pointer is allowed on the left side of the arrow (->) in C or C++.In C++ a -> operator is allowed. Side effects are not allowedSide effects such as assignments, ++, or -- are not allowed in the debugger watch window.A common error is to use x=y (not allowed) instead of x==y to test the equality of x and y. Size of 'identifier' is unknown or zeroThis identifier was used in a context where its size was needed.A struct tag might only be declared (the struct not defined yet), or an extern array might be declared without a size. It's not allowed to have some references to such an item (like sizeof) or to dereference a pointer to this type. Rearrange your declaration so that the size of 'identifier' is available. Statement missing ;The compiler encountered an expression statement without a semicolon following it. Practical Example in Exercise in Tut. 2 Structure size too largeYour source file declared a structure too large to fit into memory. (64K in ver 4.5)Subscripting missing ]This error is generated if any of the following occur:
Switch missing (A left parenthesis is missing after switch keyword.Switch missing )Too few parameters in callA call to a function with a prototype (via a function pointer) had too few arguments.Prototypes require that all parameters be given. Make certain that your call to a function has the same parameters as the function prototype. See Also Identifier expected Too many casesPFE only The compiler encountered more than 257 cases in a single switch. Too many decimal pointsThe compiler encountered a floating-point constant with more than one decimal point.Too many default casesThe compiler encountered more than one default statement in a single switch.Too many error or warning messagesThere were more errors or warnings than set in the Options|Settings|Compiler MessagesToo many exponentsThe compiler encountered more than one exponent in a floating-point constantToo many initializersThe compiler encountered more initializers than were allowed by the declaration being initialized.Too many storage classes in declarationA declaration can never have more than one storage class, either Auto, Register, Static, or Extern.Too many types in declarationA declaration can never have more than one of these basic types: char class int float double struct union enum typedef nameToo much global data defined in fileThe sum of the global data declarations exceeds 64K bytes. This includes any data stored in the DGROUP (all global variables, literal strings, and static locals).Solutions Check the declarations for any array that might be too large. You can also remove variables from the DGROUP. Here's how:
Two consecutive dotsBecause an ellipsis contains three dots (...), and a decimal point or member selection operator uses one dot (.), two consecutive dots cannot legally occur in a C program.Type mismatch in parameter 'parameter'Type mismatch in parameter 'parameter' in call to 'function'Your source file declared the function called via a function pointer with a prototype.However, the named parameter could not be converted to the declared parameter type. When compiling C++ programs, this message is always preceded by another message that explains the exact reason for the type mismatch. That other message is usually "Cannot convert 'type1' to 'type2'" but the mismatch might be due to many other reasons. Type mismatch in parameter 'number' in call to 'function'Your source file declared the named function with a prototype, and the given parameter number (counting left to right from 1) could not be converted to the declared parameter type.When compiling C++ programs, this message is always preceded by another message that explains the exact reason for the type mismatch. That other message is usually "Cannot convert 'type1' to 'type2'", but the mismatch might be due to many other reasons. Type mismatch in redeclaration of 'identifier'Your source file redeclared a variable with a different type than was originally declared for the variable.Possible Causes This can occur if a function is called and subsequently declared to return something other than an integer. Solutions If this has happened, you must declare the function before the first call to it. Unable to create output file 'filename'This error occurs if the work disk is full or write protected.This error also occurs if the output directory does not exist. Solutions If the disk is full, try deleting unneeded files and restarting the compilation. If the disk is write-protected, move the source files to a writable disk and restart the compilation. Unable to open include file 'filename'The compiler could not find the named file.Possible Causes
Unable to open input file 'filename'This error occurs if the source file can't be found.Check the spelling of the name. Make sure the file is on the specified disk or directory. Check under Options|Settings|Directories and verify that the proper directory paths are listed. If multiple paths are required, use a semi-colon to separate them, like this: C:/bc/lib;C:/bc/owl/lib or C:/T223/TURBOC/LIB Undefined label 'identifier'The named label has a goto in the function, but no label definition.See Also Identifier expected Undefined structure 'structure'(Command-line equivalent for controling display of this warning=-wstu)The named structure was used in the source file, probably on a pointer to a structure, but had no definition in the source file. This is probably caused by a misspelled structure name or a missing declaration. Default=displayed Undefined symbol 'identifier'The named identifier has no declaration.Possible Causes
Practical Example in Exercise in Tut. 2 (2 examples) Practical Example in Exercise in Tut. 3 Unexpected end of file in comment started on 'line number'The source file ended in the middle of a comment. This is normally caused by a missing close of comment (*/).Unexpected end of file in conditional started on 'line number'The source file ended before the compiler (or MAKE) encountered #endif.The #endif either was missing or misspelled. Every #if statement needs a matching #endif statement. Unknown preprocessor directive: 'identifier'The compiler encountered a # character at the beginning of a line. The directive name that followed the # was not one of the following:
Unterminated string or character constantThe compiler found no terminating quote after the beginning of a string or chr. constant.
Practical Example in Exercise in Tut. 2 User breakYou typed a Ctrl-Break while compiling in the IDE. (This is not an error, just a confirmation.)while statement missing (In a while statement, the compiler found no left parenthesis after the while keyword or test expression.while statement missing )In a while statement, the compiler found no right parenthesis after the while keyword or test expression.Wrong number of arguments in call of macro 'macro'Your source file called the named macro with an incorrect number of arguments. |