Constraints and Error Messages Overview

About this page

This page collects two things in one place: structural limits built into the compiler that no amount of correct-looking code can work around (Constraints), and the compiler’s error messages with a plain-language recommendation for fixing each one (Error Messages). If a message that has been encountered is not listed here, it is very likely a normal syntax error (a missing Then, a mismatched bracket, an undeclared variable) rather than a structural limit - re-check the line the compiler points to.

Constraints

Constraint Limit Notes

Bitwise AND/OR complexity

At most two AND/OR operations combined in one condition

More than two fails with "More than two AND/OR statements - reduce complexity." Split the comparison across two or more lines. See Conditions.

Bitwise comparisons using multiple system bit variables

Combining more than one system-generated bit variable with relational operators or braces in one comparison

Risks a silently wrong result; warns "Potential invalid BIT comparison error when using complex Bitwise logic." Suppressible with #DEFINE DISABLE1173, which does not fix the underlying risk. See Conditions.

Calculation complexity

At most 40 elements (operators and operands combined) in one calculation

Fails with "TYPECHECKSIZE exceed - reduce complexity." Break the calculation into steps using intermediate variables. See Setting Variables.

Sub/Function parameter count

At most 50 parameters per call

Fails with "Maximum number of parameters (50) exceeded." See Subroutines / Functions.

DATA block value size

0x3FFF (14-bit PIC families) / 0xFFFF (PIC18, AVR)

A value exceeding this for the target family fails to fit in one program-memory word. See DATA's Maximum Stored Value tables.

Program memory pages (baseline/mid-range PIC only)

2048 words per page; page 0 has a little less

Each Sub, Function, the main body, and the interrupt handler must fit entirely within one page. The main body, the interrupt handler, and the automatic context save/restore code are always pinned to page 0. See Program Memory Pages.

Direct array-load element count

250 elements (chip RAM < 2048 bytes) or 255 elements (chip RAM >= 2048 bytes)

Applies to the MyArray = 1,2,3,…​ load method specifically, not array declarations in general. Also, this method only supports byte arrays ("Direct array load method only supports bytes arrays").

#STARTUP count

One #STARTUP per program

A second #STARTUP fails with "Only one #STARTUP permitted."

AVRrc (reduced-core AVR) register pressure

Byte variables only; no AND/OR/XOR logic except on byte variables; use Rotate instead of multiplication

These chips have very limited registers. The compiler’s own recommendation when registers run out: "keep the code very simple."

Table source item count

Fixed capacity per table

Fails with "Out of table space. Too many items in table source." Split the data across multiple tables.

For…​Next with a Long loop variable

Step must be positive, in the range 0 to 0xFFFFFFFF

A negative Step yields incorrect results and is not detected automatically. Suppressible with SUPPRESSFORNEXTHANDLERWARNING, but the underlying restriction still applies.

For…​Next with an Integer loop variable and a negative Step

The To/From range must not cross zero - both bounds positive, or both negative

Suppressible with SUPPRESSFORNEXTHANDLERWARNING, but the underlying restriction still applies.

Nested For…​Next loop variables

Each nested loop needs its own loop variable

Reusing a loop variable already in use by an outer loop fails with "For index is already in use."

Repeat count type

Integer only

Single/Double are not permitted as a Repeat count; cast to an integer or use an integer variable/constant.

Select Case test value type

No floating-point expressions

A Select Case test value cannot be a Single/Double expression.

Pin direction control on 12-bit core chips

Whole-port direction only

12-bit core chips cannot set the direction of individual pins with Dir; the whole port’s direction is set together.

Array(element).bit as a source or destination

Not supported directly

Copy Array(element) into a temporary variable first, use temp_variable.bit, then copy back if needed - or use a constant array-element address.

Alias byte locations

Must be sequential

An alias spanning multiple RAM locations for individual bit addressing requires those locations to be sequential.

Alias and At

Mutually exclusive on the same variable

Both set the variable’s location; a variable cannot use both.

Bit variable arithmetic

Not permitted

Bit variables cannot be added or subtracted ("Illegal operation").

Bit variable comparisons

= and <> only

No other relational operator (<, >, , >=) can be used with a bit variable.

Table text content

ASCII 255 is reserved

Cannot appear inside Table text.

Overloading string-returning functions

Not supported

Subroutine/Function overloading (see Subroutines) works for other types, but not for functions that return a string.

Interrupt handler assignment

One handler per event

Assigning a second handler to the same interrupt event fails with "A handler has already been defined for the event."

Return-value syntax inside a plain Sub

Not permitted

A Sub (as opposed to a Function) cannot use return-value assignment syntax; the returned value is ignored with a warning.

Multi-bit Set (the bits method)

Literal values only

SPLLEN, IRCF3, IRCF2, IRCF1, IRCF0 = b'01111'-style multi-bit assignment cannot take its value from a variable.

Select Case multi-value Case list

At most 64 values per Case

A Case combining more than 64 comma-separated values fails with "Too many values in Case list (maximum 64)." See Select.


Error Messages

Message ID Message Text Recommendation

AliasToSelf

Variable cannot be an alias to itself

Point the Alias/At declaration at a different variable or address.

ArrayNoDec

Array/Function %Name% has not been declared

Declare the array with Dim (or check the function name for a typo) before using it.

ArrayTooBig

The array %Array% is too large

Reduce the array’s element count, or free RAM elsewhere so it fits.

ArrayTypeInvalid

Cannot set the type of an array

Remove the explicit type from the array declaration; array element type is fixed by how it’s declared.

ArrayAssignmentIncorrect

%Name% array assignment is incorrect

Check the assignment syntax against the array’s declared type and dimensions.

ASMParamMismatch

Number of parameters does not match

Check the operand count against the instruction’s expected form in the target chip’s instruction set.

AssemblerNotFound

Could not start the external assembler

Verify the assembler path in Preferences/Tool Variables, and that the executable exists.

AssemblyFailed

Assembly failed due to the following errors:

Read the assembler errors that follow this line; they identify the real problem.

BadAliasSize

Size of alias variable (%size%) does not match number of RAM locations for [%locations%]%target% variable, increase aliased bytes

Increase the alias’s byte count to match the target variable’s size.

BadBitRead

Cannot read bit %bit% of %var%

Check that the bit number is valid for the variable’s type/size.

BadBitSet

Cannot set bit %bit% of %var%

Check that the bit number is valid for the variable’s type/size.

BadBrackets

Brackets do not match up

Check for a missing or extra opening/closing bracket on the line.

BadADCConstName

Invalid constant name: %const%. Parameter should be ANx or ANxx

Use the chip’s actual analog-channel constant name, e.g. AN0.

BadCast

Cannot cast from %from% to %to%, cast here must be from larger to smaller type

Reverse the cast direction, or use an intermediate variable of the larger type.

BadCommandType

%command% command cannot be used on variables of type %type%

Use a variable of a supported type for this command, or convert the value first.

BadConfig

Configuration setting not valid: %option%

Check the #CONFIG option name/value against the chip’s supported configuration options.

BadConstName

Invalid constant name: %const%

Rename the constant - it must be a valid identifier and not a reserved word.

BadDirection

Invalid pin direction, expected In or Out

Use In or Out as the direction argument.

BadIntEvent

Invalid interrupt event: %event%

Check the event name against the chip’s supported interrupt events.

BadOnType

Bad mode: Found %found%, expected Interrupt

Check the On statement’s mode keyword; only Interrupt is valid here.

EEBadORG

Bad EEPROM location overwriting %loc%

Adjust the EEPROM data’s address so it does not overlap another dataset.

BadParam

Incorrect parameter syntax: %sub%. Correct syntax is %correct%

Match the call to the syntax shown in the message.

BadParamCount

Parameter count mismatch

Check the number of arguments passed against the Sub/Function’s declaration.

BadParamsSet

Incorrect parameters in Set, expected: Set variable.bit status

Use the form Set variable.bit status (e.g. Set PORTB.0 On).

BadPWMFreq

Invalid PWM Frequency value

Choose a PWM frequency achievable at the chip’s clock speed; see the PWM documentation for valid ranges.

BadSetStatus

Invalid status in Set command: %status%

Use a valid status keyword (e.g. On/Off) with Set.

BadStringConst

String constant cannot be first in condition

Put the variable or function call first in the comparison, with the constant second.

BadSymbol

%symbol% is not a valid symbol

Check the symbol name for a typo, or confirm it exists for the selected chip.

BadTableLocation

Bad data table location, found %loc%, expected PROGRAM or DATA

Use PROGRAM or DATA as the table’s storage location.

BadValueType

Cannot store %value% in the %type% variable %var%

Use a value compatible with the variable’s declared type, or cast it explicitly.

BadVarAlias

Variable defined with multiple aliases

Remove the duplicate Alias declaration; a variable can have only one alias.

BadVarBit

Variable %var% is of type %type% and does not have a bit %bit%

Use a bit number valid for the variable’s type/size.

BadVarName

Invalid variable name: %var%

Rename the variable - it must be a valid identifier and not a reserved word.

BadVarType

Invalid variable type: %type%

Use one of GCBASIC’s supported variable types (Byte, Word, Long, Single, etc.).

CannotConcat

%type% %value% cannot be assigned/appended to a string variable

Convert the value to a string first (e.g. with ByteToString/WordToString) before assigning/appending it.

CannotHandleArrayConstruction

Pointer mismatch: Cannot handle construct. Please check syntax, simplify source, check use of variable types, check String/Array size mismatch

Simplify the expression, and double-check variable types and array/string sizes match.

CannotHandleConstruction

Pointer mismatch: Cannot handle variable construct…​

Simplify the expression, and double-check variable types and sizes match; note which target variable/sub the message names.

CannotHandleFunctionCall

A GCBASIC library method %fn% exists but the return variable does not. Is this a call to a Subroutine rather than a Function?

Check whether %fn% is actually a Sub, not a Function, and call it accordingly.

CannotUseReservedWords

Reserved Words cannot be labels: %label%

Rename the label to something that is not a GCBASIC command/keyword.

CannotUseIncludeInsideInsert

#INCLUDE not permitted within #INSERT, move to main program

Move the #INCLUDE line out of the #INSERT block and into the main program.

ChipNotSupported

No chip data file found for %chipname%

Check the chip name for a typo, or confirm this compiler build supports that chip.

ChipIgnored

Additional #chip ignored. Using %prevchipname% as microcontroller

Remove the extra #chip line - only the first one takes effect.

ConstantExists

Constant: %constname% equates to %existingconstant_value% and cannot be reassigned to equate to %value%

Do not redefine an existing constant to a different value; use a different constant name, or #UNDEFINE it first if that is intended.

ConstantReAssignemnt

Constant: %constname% cannot be reassigned to %value%

Use a different constant name, or #UNDEFINE the existing one first if reassignment is intended.

ConstantValueReAssignement

Constant: %constname% exists with no value '%existingconstant_value%', cannot be reassigned with %value%

Give the constant its value at first definition rather than reassigning it later.

DataFound

READTABLE() cannot be to access EEPROM DATA %Table%

Use the EEPROM-specific read routine instead of ReadTable() for EEPROM-backed data.

DoWithoutCondition

Missing condition after %mode%

Add a condition after While/Until.

DoWithoutLoop

Do without matching Loop

Add the matching Loop for this Do.

DupDef

Conflicting definition for %var% sub parameter variable. %var% is a %type%. Invalid source variable type

Match the argument’s type to the parameter’s declared type, or rename one of the conflicting variables.

DuplicateSub

Duplicate subroutine name and parameters: %sub%

Rename one of the two Subs, or change one’s parameter list so they are no longer identical overloads.

ElseIfMissingThen

Invalid syntax: Use ELSE IF <condition> THEN

Add Then after the Else If condition.

ElseIfNotSupported

Invalid syntax: Use ELSE IF

Use Else If (two words) rather than ElseIf.

ElseWithoutIf

Else outside of If …​ End If block

Move the Else inside a matching If …​ End If block.

EndWithoutRepeat

End Repeat without matching Repeat

Add the matching Repeat for this End Repeat, or remove the stray End Repeat.

EssentialFileMissing

Essential file missing: %MissingFile% (listed in lowlevel.dat)

One of the header files the compiler always loads (see Development Guide for GCBASIC.EXE compiler, Note #6) could not be found - this points to a broken or incomplete GCBASIC installation, not an error in your own program. Reinstall or repair GCBASIC so the named file exists under include\lowlevel\.

ErrantElse

Single line IF statement does not support ELSE

Rewrite as a multi-line If …​ Else …​ End If block.

ExcessVars

Excessive RAM usage! Delete some variables, reduce the size of arrays, or upgrade to a more powerful chip

Free RAM by removing unused variables, shrinking arrays, or moving to a chip with more RAM.

ExtraENDIF

End If without If

Remove the extra End If, or add the missing If it was meant to close.

FirstPageFull

First page of program memory is full, please reduce size of Main and Interrupt routines

Move code out of Main/interrupt routines and into separate subroutines.

FloatInDelay

Found decimal point, but delays can only handle whole numbers

Use a whole-number delay value.

FollowOnElse

Syntax Error: Follow on #ELSE not permitted

Remove the extra #ELSE - only one is permitted per #IFDEF/#IF block.

ForBadEnd

For end value is too big for the counter

Use a loop counter variable large enough to hold the end value, or reduce the end value.

ForBadStart

For start value is too big for the counter

Use a loop counter variable large enough to hold the start value, or reduce the start value.

ForBadStart2

Invalid start value

Check the For loop’s start value/expression for errors.

ForBadStep

For-Next 'step' must be integer when start or end values are variables

Use an integer literal or Integer-typed variable for Step when Start/End are variables.

ForBadStepNegate

You cannot negate a step value. Negate the integer variable as a prior operation or pass a negative or positive value integer variable.

Negate the Step value in a separate statement before the loop, then pass the already-negative variable.

ForBadStepVariable

For-Next 'step' must be Integer variable

Use an Integer-typed variable for Step.

ForStepNeeded

For-Next 'step' integer variable must be specified when start or end values are variables - even for step 1

Add an explicit Step value/variable even if it’s just 1.

InCorrectNumberofParameters

Incorrect number of parameters

Match the call’s argument count to the Sub/Function’s declaration.

InCorrectTableFormatting

Incorrect Table Text formatting at %var%

Check quoting/comma placement in the Table source around %var%.

InCorrectTableTextTermination

Incorrectly Terminated Table Text Line

Check that each Table text line is properly closed (matching quotes).

IncorrectWaitParameter

Incorrect time unit specified. This can be an indirect error from a subroutine - so, inspect all time based constants

Check the Wait’s time unit, and any constants used for time values elsewhere in the program.

InsertedFileMissing

#INSERT file not found

Check the #INSERT file’s path and that it exists.

InvalidBit

Bit %bit% is not a valid bit and cannot be set

Use a bit number that exists on the target register/variable.

InvalidBitRead

Bit %bit% is not a valid bit and cannot be read

Use a bit number that exists on the target register/variable.

InvalidConditionalStructure

Invalid Conditional construct

Check the condition’s syntax - operators, parentheses, and operands.

InvalidDirCommand

Invalid DIRection command. Command cannot contain ','

Set one pin/port’s direction per Dir statement rather than a comma-separated list.

InvalidDoMode

Invalid loop mode %mode%, mode (if specified) must be While or Until

Use While or Until as the Do loop’s mode.

InvalidElse

Invalid #ELSE - #IFDEF or #IFNDEF not preceded

Make sure #ELSE follows an #IFDEF/#IFNDEF block.

InvalidElseCantHandle

Invalid #ELSE - cannot handle

Simplify the surrounding #IFDEF/#IF structure around this #ELSE.

InvalidNumericLiteral

Invalid numeric literal %literal% - no digits follow the prefix

A 0x or 0b prefix was written with no digits after it, for example myVar = myVar | 0x. Add the intended digits (0x0F, 0b1010), or remove the incomplete literal. The quoted forms 0b'1010' and b'1010' are unaffected.

LoopWithoutDo

Loop without matching Do

Add the matching Do for this Loop, or remove the stray Loop.

MissingCoreFile

Cannot find file %core%, which is required for %chip%

Reinstall/repair the GCBASIC installation so the missing core file is restored.

MissingFunctionAssignment

Missing Function Assignment - assign function result to a variable, or, change to a Subroutine

Assign the function’s result (e.g. MyFunc = value) before it exits, or convert it to a Sub if it does not need to return a value.

MissingOperand

Missing operand, %pos% %operator%

Add the missing value/variable on the indicated side of the operator.

MissingSubParam

Missing value for parameter %param%

Supply a value for %param%, or give it a default value in the declaration.

MissingTarget

No subroutine specified as a target

Name the subroutine to call/jump to.

MissingEndSubDef

Missing 'End Sub' or 'Return' definition or invalid 'GoSub'

Add the matching End Sub, or check the GoSub/Return pairing.

MissingSubDef

Missing Sub definition, or, missing GoSub definition, or, missing End Sub ( Return to exit/end a Sub Routine is no longer supported)

Add the missing Sub/GoSub/End Sub; note plain Return no longer ends a subroutine on its own.

MissingEndFuncDef

Missing End Function definition

Add the matching End Function.

MissingFuncDef

Missing Function definition

Add the matching Function declaration.

MissingEndDataDef

Missing End Data definition

Add the matching End Data.

MissingDataDef

Missing Data definition

Add the matching Data declaration.

NextWithoutFor

Next without matching For

Add the matching For, or remove the stray Next.

NoBit

Missing bit in Set command

Specify the bit (e.g. variable.0) in the Set statement.

NoChip

Chip model not specified! GCBASIC cannot continue

Add a #chip line naming the target microcontroller.

NoClosingComma

Missing closing comma delimiter in Table source

Add the missing comma between Table source items.

NoClosingQuote

Missing closing double quote in Table source

Add the missing closing " in the Table source string.

NoDelayUnits

Delay units not specified

Add a time unit (e.g. ms, us, s) to the Wait/delay value.

NoDestParam

Bad Destination parameter in ASM. The compiler has failed to optimise correctly. Try changing mathematical order with constants at end of order, or, post to support forum for advice/resolution.

Reorder the calculation so constants come last, or ask on the support forum with the failing line.

NoEndIf

If without matching End If

Add the matching End If.

NoEndRepeat

Repeat without End Repeat

Add the matching End Repeat.

NoFile

Cannot find %Filename%

A file the program asked for could not be found, and compilation stops. Check the spelling of the #include and that the file exists. Remember #include <name> looks in the installation’s include\ folder (not include\lowlevel\, whose libraries load automatically), while #include "name" is resolved relative to the current directory.

NOFLOATPARAMETER

No FLOAT parameter. For Singles support set to 1. See Help for details

Set the float-capability preference/option to enable Single support, per the Help section it references.

NoMatchingOverload

No matching overload found for %subname% with these argument types

None of the overloaded Sub/Function’s declared parameter lists fit the argument types given. See Subroutines for how single-character string literals and Byte/Bit parameters are matched.

NoMatchingSig

No subroutine found with matching parameters

Check the argument types/count against the available overloads of that Sub/Function.

NoNext

For without Next

Add the matching Next.

NoSelectVariableParameter

No Select Case variable specified

Give Select Case a variable or expression to test.

NoSourceParam

Bad Source parameter in ASM. The compiler has failed to optimise correctly. Try adding element(s) to complete the array definition, or, changing mathematical order with constants at end of order, or, post to support forum for advice/resolution.

Complete the array definition, reorder constants to the end of the calculation, or ask on the support forum with the failing line.

NotABitORAConst

%value% is not a bit or valid constant. Constant values should be 0 or 1

Use 0, 1, On, or Off where a bit/constant value is expected.

NotAVariable

%value% is not a variable

Use a declared variable here rather than a literal or undeclared name.

NoThen

If without Then

Add Then after the If condition.

NotIO

%var%, or your Defined CONSTANT, is not a valid I/O pin or port

Check the pin/port name (or the constant defined for it) against the chip’s actual I/O names.

NotIONOTVALID

is not a valid I/O pin or port

Check the pin/port name against the chip’s actual I/O names.

NotaValidDirective

Not a valid directive %directive%

Check the #-directive name for a typo against GCBASIC’s supported directives.

OperandTypeMismatch

Operand %operand% cannot be used with %type% variables

Use an operand compatible with the variable’s type, or convert the variable’s type first.

OutOfProgMem

Program is too large, cannot fit all subroutines into available program memory

Reduce code size or move to a chip with more program memory.

OutOfProgMemExceeded

Program is too large, cannot fit into available program memory

Reduce code size or move to a chip with more program memory.

OutOfRegSpace

Out of registers. Please break up any complex calculations

Split the calculation into smaller steps using intermediate variables.

PICASFailtoLaunch

PIC-AS failed to execute: %var%

Check the PIC-AS install path in Preferences/Tool Variables.

ReadADMissingparentheses

READAD

READAD10

READAD12 function(s) required parentheses () as parameter delimiters

Add parentheses around the argument, e.g. ReadAD(AN0).

RecursiveDefine

Recursive define

Break the circular #define chain - a constant cannot be defined in terms of itself.

RepeatMissingCount

No value given for Repeat

Give Repeat a count.

ShouldNotUseConstant

Select Case should not use a Constant

Test a variable/expression in Select Case, not a compile-time constant (the outcome would always be the same branch).

SubAndVarNameConflict

Variable %var% cannot be created, a subroutine already has this name

Rename the variable, or rename the conflicting subroutine.

SubNotFound

Subroutine %sub% could not be found

Check the subroutine name for a typo, and confirm it (or its library) is included.

SubParamNotVar

%value% is not a variable and cannot be used for the parameter %param%

Pass a declared variable for this parameter rather than a literal or expression.

SubTooBig

Subroutine %sub% is too large. Reduce its size, or switch to a more powerful chip

Split the subroutine into smaller ones, or use a chip with more program memory.

SymbolNotDefined

Symbol [SFR]%symbol% has not been defined. Inspect ASM file to determine error

Check the generated ASM file around this symbol to find what is missing.

SynErr

Syntax Error

Re-check the line’s syntax against the command’s documentation.

SynErrIncorrectBitDestination

Syntax Error - cannot assign string to bit variable

Assign a bit value (0/1/On/Off), not a string, to a bit variable.

SynErrIncorrectByteDestination

Syntax Error - cannot assign string to byte variable. Use ByteToString()

Convert with ByteToString() if you actually want the byte’s string representation, or assign a numeric value instead.

SynErrIncorrectWordDestination

Syntax Error - cannot assign string to word variable. Use WordToString()

Convert with WordToString() if you actually want the word’s string representation, or assign a numeric value instead.

SynErrIncorrectLongDestination

Syntax Error - cannot assign string to long variable. Use LongToString()

Convert with LongToString() if you actually want the long’s string representation, or assign a numeric value instead.

SynErrIncorrectSingleDestination

Syntax Error - cannot assign string to single variable. Use SingleToString()

Convert with SingleToString() if you actually want the single’s string representation, or assign a numeric value instead.

TableItemInvalid

Item %item% cannot be stored in the table

Check the item’s type/value against what the table’s declared type can hold.

TableNotFound

Lookup table %Table% not found

Check the table name for a typo, and confirm it is declared before use.

TooManyCaseValues

Too many values in Case list (maximum %max%)

Split the value list across more than one Case line, each running the same code, or restructure using a To range where the values are contiguous. See Select.

TooManyErrors

Too many errors

Fix the errors reported so far and recompile - the compiler stopped early because there were too many to usefully continue.

UndeclaredArray

Array %array% has not been declared

Add a Dim declaration for the array before using it.

UndeclaredVar

Variable %var% was not explicitly declared

Add a Dim declaration for the variable (required under #Option Explicit).

UndeclaredMacroVar

Macro variable %var% not declared - type unknown

Give the macro variable an explicit type where it’s first used.

UnhandledHexToSingleAssignement

Unhandled hex value. Use byte component addressing for Hex value to Single variable assignment

Assign to the Single variable’s individual byte components rather than the hex value directly.

UsartBaudTooLow

USART baud rate is too low

Choose a higher baud rate achievable at the chip’s clock speed.

UseSYSDEFAULTCONCATSTRING

See Also:

  • Conditions — the AND/OR and bit-comparison constraints in context
  • Setting Variables — the calculation-complexity constraint in context
  • Subroutines — the parameter-count and page-size constraints in context
  • Functions — the parameter-count constraint in context
  • DATA — the DATA block value-size constraint in context