Syntax and Semantic Errors

Syntax and semantic errors typically occur in the source program. They identify actual programming errors. When one of these errors is encountered, the compiler attempts to recover from the error and continue processing the source file. As more errors are encountered, the compiler outputs additional error messages. However, no object file is produced.

Syntax and semantic errors produce a message in the list file. These error messages are in the following format:

*** ERROR number IN LINE line OF file: error message
where:

number    is the error number.

line    corresponds to the line number in the source file or include file.

file    is the name of the source or include file in which the error was detected.

error message    is descriptive text and is dependent on the type of error encountered.

The following table lists syntax and semantic errors by error number. The error message displayed is listed along with a brief description and possible cause and correction.

Number

Message and Description

100

unprintable character 0x?? skipped
An illegal character was found in the source file. (Note that characters inside a comment are not checked.)

101

unclosed string
A string is not terminated with a quote (").

102

string too long
A string may not contain more than 1024 characters. Use the concatenation symbol (\) to logically continue strings longer than 1024 characters. Lines terminated in this fashion are concatenated during lexical analysis.

103

invalid character constant
A character constant has an invalid format. The notation ‘\c’ is valid only when c  is any printable ASCII character.

125

declarator too complex (20)
The declaration of an object may contain a maximum of 20 type modifiers ([ ], *, ()). This error is almost always followed by error 126.

126

typestack underflow
The type declaration stack has underflowed. This error is usually a side-effect of error 125.

127

invalid storage class
An object was declared with an invalid memory space specification.  This occurs if an object is declared with storage-class of auto or register outside of a function.

129

missing ';' before 'token'
This error usually indicates that a semicolon is missing from the previous line. When this error occurs, the compiler may generate an excess of error messages.

130

value out of range
The numerical argument after a using or interrupt specifier is invalid. The using specifier requires a register bank number between 0 and 3. The interrupt specifier requires an interrupt vector number between 0 and 15.

131

duplicate functionparameter
A formal parameter name exists more than once within a function. The formal parameter names must be unique in function declarations.

132

not in formal parameter list
The parameter declarations inside a function use a name not present in the parameter name list. For example:

char function (v0, v1, v2)
char *v0, *v1, *v5;
/* 'v5' is unknown in the formal list */
{
  /* ... */
}

134

xdata/idata/pdata/data on function not permitted
Functions always reside in code memory and cannot be executed out of other memory areas. Functions are implicitly defined as memory type code.

135

bad storage class for bit
Declarations of bit-scalars may include one of the static or extern storage classes. The register or alien classes are invalid.

136

'void' on variable
The type void is only allowed as a non-existent return value or an empty argument list for functions (void func (void)), or in combination with a pointer (void *).

138

interrupt() may not receive or return value(s)
An interrupt function was defined with one or more formal parameters or with a return value. Interrupt functions may not contain invocation parameters or return values.

140

bit in illegal memoryspace
Definitions of bit scalars may contain the optional memory type data. If the memory type is missing then the type data is assumed, because bits always reside in the internal data memory. This error can occur when an attempt is made to use another data type with a bit-scalar definition.

141

NEAR token: expected ???,...
The token  as seen by the compiler is wrong. If token  is one of less than four tokens, an optional display of expected tokens may follow.

142

invalid base address
The base-address of an sfr or sbit declaration is in error. Valid bases are values in the range of 0x80 to 0xFF. If the declaration uses the notation base^pos, then the base address must also be a multiple of eight.

143

invalid absolute bit address
The absolute address in sbit declarations must be in range 0x80 to 0xFF.

144

base^pos: invalid bit position
The definition of the bit position within an sbit declaration must be in range 0 to 7.

145

undeclared sfr

146

invalid sfr
The declaration of an absolute bit (base^pos) contains an invalid base-specification. The base must be the name of a previously declared sfr.  Any other names are invalid.

147

object too large
The size of a single object may not exceed the absolute limit of 65535  64K-1 bytes.

149

function member in struct/union
A struct or union may not contain a function-type member. However, pointers to functions are perfectly valid.

150

bit member in struct/union
A union-aggregate may not contain members of type bit. This restriction is imposed due to the architecture of the 8051.

151

self relative struct/union
A structure cannot contain an instance of itself.

152

bitfield type too small for number of bits
The number of bits specified in the bit-field declaration exceeds the number of bits in the given base type.

153

named bitfield cannot have 0 width
The named field had a zero width. Only unnamed bit-fields are allowed to have zero width.

154

ptr to field
Pointers to bit-fields are not valid types.

155

char/int required for fields
The base type for bit-fields requires one of the types char or int. unsigned char and unsigned int types are also valid.

156 157

alien permitted on functions onlyVar_parms on alien function
The storage class alien is allowed only for external PL/M-51 functions. The formal notation (char *, ...) is not legal on alien functions. PL/M-51 functions always require a fixed number of parameters.

158

function contains unnamed parameter
The parameter list of a function definition contains an unnamed abstract type definition. This notation is permitted only in function prototypes.

159

type follows void
Prototype declarations of functions may contain an empty parameter list (e.g., int func (void)). This notation may not contain further type definitions after void.

160

void invalid
The void type is legal only in combination with pointers or as the non-existent return value of a function.

161

formal parameter ignored
A declaration of an external function inside a function used a parameter name list without any type specification (e.g., extern yylex(a,b,c);).

162

duplicate functionparameter
The name of a defined object inside a function duplicates the name of a parameter.

163

unknown array size
In general, single or multi-dimensional arrays, and external arrays are not required to have a formal size specifier. Typically, the size is calculated by the compiler at initialization time or, as is the case with the external arrays, is simply of no great interest. This error is the result of attempting to use the sizeof operator on an undimensioned array or on a multi-dimensional array with undefined element sizes.

164

ptr to nul
This error is usually the result of a previous error for a pointer declaration.

165

ptr to bit
The type combination pointer to bit is not a legal type.

166

array of functions
Arrays cannot contain functions; however, they may contain pointers to functions.

167

array of fields
Bit-fields may not be arranged as arrays.

168

array of bit
An array may not have type bit as its basic-type. This limitation is imposed by the architecture of the 8051.

169

function returns function
A function cannot return a function; however, a function may return a pointer to a function.

170

function returns array
A function cannot return an array; however, a pointer to an array is valid.

171

missing enclosing loop
A break or continue statement may occur only within a for, while, do, or switch statement.

172

missing enclosing switch
A case statement may occur only within a switch statement.

173

missing returnexpression
A function which returns a value of any type but int, must contain a return statement including an expression. Because of compatibility to older programs, no check is done on functions which return an int value.

174

returnexpression on voidfunction
A void function cannot return a value and thus may not contain a return statement.

175

duplicate case value
Each case statement must contain a constant expression as its argument. The value must not occur more than once in the given level of the switch statement.

176

more than one 'default'
A switch statement may not contain more than one default statement.

177

different struct/union
Different types of structures are used in an assignment or as an argument to a function.

178

struct/union comparison illegal
The comparison of two structures or unions is not allowed according to ANSI.

179

can't cast from/to voidtype
Type-casts to or from void are invalid.

180

can't cast to 'function'
Type-casts to function types are invalid. Try casting to a pointer to a function.

181

incompatible operand
At least one operand-type is not valid with the given operator (e.g., ~float_type).

183

unmodifiable lvalue
The object to be changed resides in code memory and therefore cannot be modified.

184

sizeof: illegal operand
The sizeof operator cannot determine the size of a function or bit-field.

185

different memory space
The memory space of an object declaration differs from the memory space of a prior declaration for the same object.

186

invalid dereference
This error message may be caused by an internal compiler problem. Please contact technical support if this error is repeated.

187

not an lvalue
The needed argument must be the address of an object that can be modified.

188

unknown object size
The size of an object cannot be computed because of a missing dimension size on an array or indirection via a void pointer.

189

'&' on bit/sfr illegal
The address-of operator (&) is not allowed on bit-objects or special-function-registers (sfr).

190

'&': not an lvalue
An attempt was made to construct a pointer to an anonymous object.

193
193
193
193

illegal optype(s)
illegal add/sub on ptr
illegal operation on bit(s)
bad operand type
This error results when an expression uses illegal operand-types with the given operator. Examples of invalid expressions are bit * bit, ptr + ptr, or ptr * any. The error message includes the operator which caused the error.

The following operations may be executed with bit-type operands:

    Assignment (=)

    OR / Compound OR (|, |=)

    AND / Compound AND (&, &=)

    XOR / Compound XOR (^, ^=)

    Compare bit with bit or constant (==, !=)

    Negation (~)

bit operands may be used in expressions with other data types. In this case a type-cast is automatically performed.

194

'*' indirection to object of unknown size
The indirection operator * may not be used with void pointers because the object size, which the pointer refers to, is unknown.

195

'*' illegal indirection
The * operator may not be applied on non-pointer arguments.

198

sizeif returns zero

The sizeof operator returns a zero value

199

left side of '->' requires struct/union pointer
The argument on the left side of the > operator must be a struct pointer or a union pointer.

200

left side of '.' requires struct/union
The argument on the left side of the . operator must have type struct or union.

201

undefined struct/union tag
The given struct or union tag name is unknown.

202

undefined identifier
The given identifier is undefined.

203

bad storage class (nameref)
This error indicates a problem within the compiler. Please contact technical support if this error is repeated.

204

undefined member
The given member name in a struct or union reference is undefined.

205

can't call an interrupt function
An interrupt function should not be called like a normal function. The entry and exit code for these functions is specially coded for interrupts.

207

declared with 'void' parameter list
A function declared with a void parameter list cannot receive parameters from the caller.

208

too many actual parameters
The function call includes more parameters than previously declared.

209

too few actual parameters
Too few actual parameters were included in a function call.

210

too many nested calls
Function calls can be nested at most 10 levels deep.

211

call not to a function
The term of a function call does not evaluate to a function or pointer to function.

212

indirect call:parameters do not fit within registers

An indirect function call through a pointer cannot contain actual parameters. An exception to this rule is when all parameters can be passed in registers. This is due to the method of parameter passing employed by C51. The name of the called function must be known because parameters are written into the data segment of the called function. For indirect calls, however, the name of the called function is unknown.

213

left side of asnop not an lvalue
The address of a changeable object is required at the right side of the assignment operator.

214

illegal pointer conversion
Objects of type bit, float or aggregates cannot be converted to pointers.

215

illegal type conversion
Struct/union/void cannot be converted to any other types..

216

subscript on nonarray or too many dimensions
An array reference contained either too many dimension specifiers or the object was not an array.

217

nonintegral index
The dimension expression of an array must be of the type char, unsigned char, int, or unsigned int. All other types are illegal.

218

voidtype in controlling expression
The limit expression in a while, for, or do statement cannot be of type void.

219

long constant truncated to int
The value of a constant expression must be capable of being represented by an int type.

220

illegal constant expression
A constant expression is expected. Object names, variables or functions, are not allowed in constant expressions.

221

nonconstant case/dim expression
A case value or a dimension specification ([ ]) must be a constant expression.

222
223

div by zero
mod by zero
The compiler detected a division or a module by zero.

225

expression too complex, simplify
An expression is too complex and must be broken into two or more sub expressions.

226

duplicate struct/union/enum tag
The name for a struct, union, or enum is already defined within current scope.

227

not a union tag
The name for a union is already defined as a different type.

228

not a struct tag
The name for a struct is already defined as a different type.

229

not an enum tag
The name for an enum is already defined as a different type.

230

unknown struct/union/enum tag
The specified struct, union, or enum name is undefined.

231

redefinition
The specified name is already defined and cannot be redefined.

232

duplicate label
The specified label is already defined.

233

undefined label
This message indicates a label that was accessed but was not defined. Sometimes this message appears several lines after the actual label reference.  This is caused by the method used to search for undefined labels.

234

'{', scope stack overflow(31)
The maximum of 31 nested blocks has been exceeded. Additional levels of nested blocks are ignored.

235

parameter <number>: different types
Parameter types in the function declaration are different from those in the function prototype.

236

different length of parameter lists
The number of parameters in the function declaration is different from the number of parameters in the function prototype.

237

function already has a body
An attempt was made to declare a body for a function twice.

238
239

duplicate member
duplicate parameter
An attempt was made to define an already defined struct member or function parameter.

240

more than 128 local bit's
No more than 128 bit scalars may be defined inside a function.

241

auto segment too large
The required space for local objects exceeds the model-dependent maximum. The maximum segment sizes are defined as follows:

    SMALL    128 bytes
    COMPACT    256 bytes
    LARGE    64 KBytes

242

too many initializers
The number of initializers exceeded the number of objects to be initialized.

243

string out of bounds
The number of characters in the string exceeds the number of characters required to initialize the array of characters.

244

can't initialize, bad type or class
An attempt was made to initialize a bit or an sfr.

245

unknown pragma, line ignored
The #pragma statement is unknown so, the entire line is ignored.

246

floating point error
This error occurs when a floating point argument lies outside of the valid range for 32-bit floating values. The numeric range of the 32-bit IEEE values is: ±1.175494E-38 to ±3.402823E+38.

247

nonaddress/constant initializer
A valid initializer expression must evaluate to a constant value or the name of an object plus or minus a constant.

248

aggregate initialization needs curly braces
The braces ({}) around the given struct or union initializer were missing.

249

SEGMENT <name>: SEGMENT TOO LARGE
The compiler detected a data segment that was too large. The maximum size of a data segment depends on memory space.

250

'\esc'; value exceeds 255"
An escape sequence in a string constant exceeds the valid value range. The maximum value is 255.

251

illegal octal digit
The specified character is not a valid octal digit.

252

misplaced primary control, line ignored
Primary controls must be specified at the start of the C module before any #include directives or declarations.

253

internal error (ASMGEN\CLASS)
This error can occur under the following circumstances:

    An intrinsic function (e.g., _testbit_) was activated incorrectly.  This is the case when no prototype of the function exists and the number of actual parameters or their type is incorrect. For this reason, the appropriate declaration files must always be used (intrins.h, string.h). See chapter 9 regarding intrinsic functions.

    C51 recognized an internal consistency problem. Please contact technical support if this error occurs.

255

switch expression has illegal type
The expression in a switch statement must be one of the following types:

char    unsigned char    int
unsigned int
    short    unsigned short

other types are not permitted.

256

conflicting memory model
A function which contains the alien attribute may contain only the model specification small. The parameters of the function must lie in internal data memory. This applies to all external alien declarations and alien functions. For example:

alien plm_func (char c) large { ... }

generates error 256.

257

alien function cannot be reentrant
A function that contains the alien attribute cannot simultaneously contain the attribute reentrant. The parameters of the function cannot be passed via the virtual stack. This applies to all external alien declarations and alien functions.

258

mspace illegal on struct/union member
mspace on parameter ignored


A member of a struct may not contain the specification of a memory type. The object to which the pointer refers may, however, contain a memory type. For example:

struct vp { char code c; int xdata i; };

generates error 258.

struct v1 { char c; int xdata *i; };

is the correct declaration for the struct.

259

pointer: different mspace
A spaced pointer has been assigned another spaced pointer with a different memory space.
For Example:
char xdata *p1;
char idata *p2;
p1=p2;     /* different memory spaces */

260

pointer truncation
A spaced pointer has been assigned some constant value which exceeds the range covered by the pointers memory space.
For Example:
char idata *p1=0x1234;   /* result is 0x34 */

261

bit(s) in reentrant ()
A function with the attribute reentrant cannot have bit objects declared inside the function. 
For Example:
int func1 (int I1) reentrant {
  bit b1, b2;    /* not allowed */
  return (I1 - 1);
}

262

'using/disable': function returns bit
Functions declared with the using attribute and functions which rely on disabled interrupts (#pragma disable) cannot return a bit value to the caller. For example:

bit test (void) using 3
{
bit b0;
return (b0);
}

produces error 262.

263

savestack overflow/underflow
The maximum nesting depth #pragma save comprises eight levels. The pragmas save and restore work with a stack according to the LIFO (last in, first out) principal.

264

intrinsic '<intrinsic_name>': declaration/activation error
This error indicates that an intrinsic function was defined incorrectly (parameter number or ellipsis notation). This error should not occur if you are using the standard .H files. Make sure that you are using the .H files that were included with C51. Do not try to define your own prototypes for intrinsic library functions.

265

'<name>': recursive call to non-reentrant function
A direct recursion to a non-reentrant function was discovered. This can be intentional, but is to be functionally checked in individual cases by means of the generated code. Indirect recursion is discovered by L51.

267

funcdef requires ANSI-parameter list
A function was invoked with parameters but the declaration specifies an empty parameter list. The prototype should be completed with the parameter types in order to give the compiler the opportunity to pass parameters in registers and have the calling mechanism consistent over the application.

268

bad taskdef (taskid/priority/using)
The task declaration is incorrect.

271

misplaced 'asm/endasm' control
The asm and endasm statements may not be nested. Endasm requires that an asm block was opened by a previous asm statement. For example:

#pragma asm
.
.
.
assembler instruction(s)
.
.
.
#pragma endasm

272

'asm' requires SRC control to be active
The use of asm and endasm in a source file requires that the file is compiled using the SRC directive. The compiler then generates an assembly source file which may then be assembled with A51.

273

'asm/endasm' not allowed in include file
The use of asm and endasm is not permitted within include files. For debug reasons executable code should be avoided in include files anyway.

274

absolute specifier illegal
The absolute address specification is not allowed on bit objects and functions. The address must conform to the memory space of the object. For example, the following declaration is invalid because the range of the indirectly addressable data space is 0x00 to 0xFF.

idata int at 0x1000;

278

constant to big
This error occurs when a floating-point argument lies outside of the valid range for 32-bit floating values. The numeric range of the 32-bit IEEE values is: ±1.175494E-38 to ±3.402823E+38

279

multiple initialization
An attempt has been made to initialize some object more than once.

300

unterminated comment
This message occurs when a comment does not have a closing delimiter (*/).

301

identifier expected
The syntax of a preprocessor directive expects an identifier.

302

misused # operator
This message occurs if the stringize operator ‘#’ is not followed by an identifier.

303

formal argument expected
This message occurs if the stringize operator ‘#’ is not followed by an identifier representing a formal parameter name of the macro currently being defined.

304

bad macro parameter list
The macro parameter list does not represent a brace enclosed, comma separated list of identifiers.

305

unterminated string/char constant
A string or character constant is invalid. Typically, this error is encountered if the closing quote is missing.

306

unterminated macro call
The end of the input file was reached while the preprocessor was collecting and expanding actual parameters of a macro call.

307

macro 'name': parameter count mismatch
The number of actual parameters in a macro call does not match the number of parameters of the macro definition. This error indicates that too few parameters were specified.

308

invalid integer constant expression
The numerical expression of an if/elif directive contains a syntax error.

309

bad or missing file name
The filename argument in an include directive is invalid or missing.

310

conditionals too nested(20)
The source file contains too many nested directives for conditional compilation. The maximum nesting level allowed is 20.

311
312

misplaced elif-else control
misplaced endif control
The directives elif, else, and endif are legal only within an if, ifdef, or ifndef directive.

313

can't remove predefined macro 'name'
An attempt was made to remove a predefined macro. Existing macros may be deleted using the #undef directive. Predefined macros cannot be removed. The compiler recognizes the following predefined macros:

_ _C51_ _        _ _DATE_ _        _ _FILE_ _
_ _MODEL_ _
    _ _LINE_ _        _ _STDC_ _
_ _TIME_ _

314

bad # directive syntax
In a preprocessor directive, the character '#' must be followed by either a newline character or the name of a preprocessor command (e.g. if/define/ifdef, ...).

315

unknown # directive 'name'
The name of the preprocessor directive is not known to the compiler.

316

unterminated conditionals
The number of endifs does not match the number of if or ifdefs after the end of the input file.

318

can't open 'filename'
The given file could not be opened.

319

'file' is not a disk file
The given file is not a disk file. Files other than disk files are not legal for compilation.

320

user_error_text
This error number is reserved for errors introduced with the #error directive of the preprocessor. The #error directive causes the user error text to come up with error 320 which counts like some other error and prevents the compiler from generating code.

321

missing <character>

In the filename argument of an include directive, the closing character is missing.

For Example:

#Include <stdio.h

325

duplicate formal parameter ‘name’

A formal parameter of a macro may be defined only once.

326

macro body cannot start or end with ‘##’

The concat operator (##) cannot be the first or last token of a macro body

327

macro ‘macroname’: more than 50 parameters

The number of parameters per macro is limited to 50