Target Language Compiler | ![]() ![]() |
TLC Error Messages
This section lists and describes error messages generated by the Target Language Compiler (tlc.mex
). Use this reference to
%closefile or %selectfile or %flushfile argument must be a valid open file
When using %closefile
or %selectfile
or %flushfile
, the argument must be a valid file variable opened with %openfile
.
%define no longer supported, use %function instead
Macros are no longer supported. You must rewrite all macros as functions or inline them in your code.
%error directive: text
Code containing the %error
directive generates this message. It normally indicates some condition that the code was unable to handle and displays the text following the %error
directive.
%exit directive: text
Code containing the %exit
directive causes this message. It typically indicates some condition that the code was unable to handle and displays the text following the %exit
directive. Note that this directive causes the Target Language Compiler to terminate regardless of the -mnumber
command line option.
%filescope has already been used in this file.
The user attempted to use the %filescope
directive more than once in a file.
%trace directive: text
The %trace
directive produces this error message and displays the text following the %trace
directive. Trace directives are only reported when the -v
option (verbose mode) appears on the command line. Note that %trace
directives are not considered errors and do not cause the Target Language Compiler to stop processing.
%warning directive: %s
The %warning
directive produces this error message and displays the text following the %warning
directive. Note that %warning
directives are not considered errors and do not cause the Target Language Compiler to stop processing.
A %implements directive must appear within a block template file and must match the %language and type specified
A block template file was found, but it did not contain a %implements
directive. A %implements
directive is required to ensure that the correct language and type are implemented by this block template file. See Object-Oriented Facility for Generating Target Code for more information.
A %switch statement can only have one %default
The user has written a %switch
statement with multiple %default
cases, as in the following example:
%switch expr %case 1 code... %break %default more code... %break %default %% error even more code... %break %endswitch
A language choice must be made using the %language directive prior to using GENERATE or GENERATE_TYPE
To use the GENERATE
or GENERATE_TYPE
built-in functions, the Target Language Compiler requires that you first specify the language being generated. It does this to ensure that the block-level target file implements the same language and type as specified in the %language
directive.
A non-homogenous vector was passed to GENERATE_FORMATTED_VALUE
The builtin GENERATE_FORMATTED_VALUE
can only process vectors which have homogenous elements (that is, vectors in which all the elements have the same type).
Ambiguous reference to identifier -- must use array index to refer to one of multiple scopes
When using a repeated scope identifier from a database file, you must specify an index in order to disambiguate the reference. For example:
Database file:
block { Name "Abc2" Parameter { Name "foo" Value 2 } } block { Name "Abc3" Parameter { Name "foo" Value 3 } }TLC file:
%assign y = block
In this example, the reference to block is ambiguous because multiple repeated scopes named "block" appear in the database file. Use an index to disambiguate it, as in
An %if statement can only have one %else
The user has written an %if
statement with multiple %else
blocks, as in the following example.
Argument to identifier must be a string
The following built-in functions expect a string and report this error if the argument passed is not a string.
CAST |
GENERATE_FILENAME |
EXISTS |
GENERATE_FUNCTION_EXISTS |
FEVAL |
GENERATE_TYPE |
FILE_EXISTS |
GET_COMMAND _SWITCH |
FORMAT |
IDNUM |
GENERATE |
SYSNAME |
Arguments to directive must be records
Arguments to %mergerecord
and %copyrecord
must be records. Also, the first argument to the following builtins must be records:
Arguments to TLC from the MATLAB command line must be strings
An attempt was made to invoke the Target Language Compiler from MATLAB and some of the arguments that were passed were not strings.
Assertion failed
An expression in an %assert
statement evaluated to false.
Assignment to scope identifier is only allowed when using the + operator to add members
Scope assignment must be scope = scope + variable
.
Attempt to define a function identifier on top of an existing variable or function
A function cannot be defined twice. Make sure that you don't have the same function defined in separate TLC files.
Attempt to divide by zero
The Target Language Compiler does not allow division by zero.
Bad cast - unable to cast this expression to "type"
The Target Language Compiler does not know how to cast this expression from its current type to the specified type. For example, the Target Language Compiler is not able to cast a string to a number as in
Bad directory (dirname) in -O: filename
The -O
option was not a valid directory.
builtin was expecting expression of type type, got one of type type
A builtin was passed an expression of incorrect type.
Cannot %undef any builtin functions or variables
User is not allowed to %undef
any TLC builtins or variables, for example
Cannot convert string your_string to a number
Cannot convert the string to a number.
Changing value of identifier from the RTW file
You have overwritten the value that appeared in the RTW file.
Error opening "filename"
The Target Language Compiler could not open the file specified on the command line.
Error writing to file "error"
There was an error while writing to the current output stream. "
error
"
will contain the system specific error message.
Errors occurred -- aborting
This error message is always the last error to be reported. It occurs when:
Expansion directives %<> cannot be nested
It is illegal to nest expansion directives. For example:
Expansion directives %<> cannot span multiple lines; use \ at end of line
An expansion directive cannot span multiple lines. To work around this restriction, use the \
line continuation character. For example,
Extra arguments to the function-name built-in function were ignored (Warning)
The following built-in functions report this warning when too many arguments are passed to them.
CAST |
NUMTLCFILES |
EXISTS |
OUTPUT_LINES |
FILE_EXISTS |
SIZE |
FORMAT |
STRING |
GENERATE_FILENAME |
STRINGOF |
GENERATE_FUNCTION_EXISTS |
SYSNAME |
IDNUM |
TLCFILES |
ISFINITE |
TYPE |
ISINF |
WHITE_SPACE |
ISNAN |
WILL_ROLL |
File name too long (directory = 'dirname', name = 'filename')
The specified filename was too long. The default limits are 256 characters for filename and 1024 characters for pathname, but the limits may be larger depending on the platform.
format is not a legal format value
The specified format was not legal for the %realformat
directive. Valid format strings are "EXPONENTIAL"
and "CONCISE"
.
Function argument mismatch; function function_name expects number arguments
When calling a function, too many or too few arguments were passed to it.
Function reached the end and did not return a value
Functions that are not declared as void
or Output
must return a value. If a return value is not desired, declare the function as void
, otherwise ensure that it always returns a value.
Function values are not allowed
Attempt to use a TLC function as a variable.
Identifier identifier multiply defined. Second and succeeding definitions ignored.
The user is attempting to add the same field to a record more than once, as in the following code.
Identifier identifier used on a %foreach statement was already in scope (Warning)
The argument to a %foreach
statement cannot be defined prior to entering the %foreach
.
Illegal use of eval (i.e. %<...>)
It is illegal to use evals in .rtw
files. There are also some places where evals are not allowed in directives, for example
Indices may not be negative
An index used in a []
expression must be a nonnegative integer.
Indices must be constant integral numbers
An index used in a []
expression must be an integral number.
Invalid handle
An invalid handle was passed to the Target Language Compiler Server Mode.
Invalid identifier range, the leading strings string1 and string2 must match
When using a range of signals, for example, u1:u10
, the identifier in the first argument did not match the identifier in the second.
Invalid identifier range, the lower bound (%d) must be less than the upper bound (%d)
When using a range of signals, for example, u1:u10
, the lower bound was higher than the upper bound.
Invalid type for unary operator
Unary operators -
and +
require numeric types. Unary operator ~
requires an integral type. Unary operator !
requires a numeric type.
Invalid type type
An invalid type was passed to a built-in function.
It is illegal to return a function from a function
A function value cannot be returned from a function call.
Named value identifier already exists within this scope-identifier; use %assign to change the value
You cannot use the block addition operator +
to add a value that is already a member of the indicated block. Use %assign
to change the value of an existing value. This example produces this error:
No %case statement(s) seen yet, statement ignored.
Statements that appear inside a %switch
statement, but precede any %case
statements, are ignored, as in the following code.
Only double and character arrays can be converted from MATLAB to TLC. This can occur if the MATLAB function does not return a value (see %matlab).
Only double and character arrays can be converted from MATLAB to the Target Language Compiler. This error can occur if the MATLAB function does not return a value (see %matlab
). For example:
Only one output is allowed from the TLC
An attempt was made to receive multiple outputs from the MATLAB version of the Target Language Compiler.
Only strings of length 1 can be assigned using the [] notation
The right-hand side of a string assignment using the []
operator must be a string of length 1. You can only replace a single character using this notation.
Only strings or cells of strings may be used as the argument to Query and ExecString
A cell containing nonstring data was passed as the third argument to Query
or ExecString
in Server Mode.
Only vectors of the same length as the existing vector value can be assigned using the [] notation
When using the []
notation to replace a row of a matrix, the row must be a vector of the same length as the existing rows.
Output file identifier opened with %openfile was not closed
Output files opened with %openfile
must be closed with %closefile
. identifier
is the name of the variable specified in the %openfile
directive.
Note
This might also occur if there is a syntax error in your code section between an openfile and closefile , or if you try to assign the output of a function of type void or Output to a variable.
|
Ranges, identifier ranges, and repeat values cannot be repeated
You cannot repeat a range, idrange, or repeat value. This prevents things like [1@2@3]
.
String cannot modify the setting for the command line switch '-switch'
%setcommandswitch
does not recognize the specified switch, or cannot modify it (e.g., -r
cannot be modified).
'String' is not a recognized user defined property of this handle
The query performed on a TLC server mode handle is looking for an undefined property.
Syntax error
The indicated line contains a syntax error, See Directives and Built-in Functions, for information on the syntax.
The %break directive can only appear within a %foreach, %for, %roll, or %switch statement
The %break
directive can only be used in a %foreach
, %for
, %roll
, or %switch
statement.
The %case and %default directives can only be used within the %switch statement
A %case
or %
default
directive can only appear within a %switch
statement.
The %continue directive can only appear within a %foreach, %for, or %roll statement
The %continue
directive can only be used in a %foreach
, %for
, or %roll
statement.
The %foreach statement expects a constant numeric argument
The argument of a %foreach
must be a numeric type. For example,
%foreach
cannot accept a vector as input.
The %if statement expects a constant numeric argument
The argument of a %if
must be a numeric type. For example:
%if
cannot accept a vector as input.
The %implements directive expects a string or string vector as the list of languages
You can use the %implements
directive to specify a string for the language being implemented, or to indicate that it implements multiple languages by using a vector of strings. You cannot specify any other argument type to the %implements
directive.
The %implements directive specifies type as the type where type was expected
The type specified in the %implements
directive must exactly match the type specified in the block or on the GENERATE_TYPE
directive. If you want to specify that the block accept multiple input types, use the %implements *
directive, as in
The %implements language does not match the language currently being generated (language)
The language or languages specified in the %implements
directive must exactly match the %language
directive.
The %return statement can only appear within the body of a function
A %return
statement can only be in the body of a function.
The == and != operators can only be used to compare values of the same type
The ==
and !=
operator arguments must be the same type. You can use the CAST()
built-in function to change them into the same type.
The argument for %openfile must be a valid string
When opening an output file, the name of the file must be a valid string.
The argument for %with must be a valid scope
The argument to %with
must be a valid scope identifier. For example:
In this code, the %with
statement argument is a number and produces this error message.
The argument for an [] operation must be a repeated scope symbol, a vector, or a matrix
When using the []
operator to index, the expression on the left of the brackets must be a vector, matrix, string, numeric constant, or a repeated scope identifier. When using array indexing on a scalar, the constant is automatically scalar expanded and the value of the scalar is returned. For example:,
This example would cause this error because x
is a file and is not valid for indexing.
The argument to %addincludepath must be a valid string
The argument to %addincludepath
must be a string.
The argument to %include must be a valid string
The argument to the input file control directive must be a valid string with the filename given in double quotes.
The begin directive must be in the same file as the corresponding end directive.
These Target Language Compiler begin
directives must appear in the same file as their corresponding end
directives: %function
, %switch
, %foreach
, %roll
, and %for
. Place the construct entirely within one Target Language Compiler source file.
The begin directive on this line has no matching end directive
For block-scoped directives, this error is produced if there is no matching end
directive. This error can occur for the following block-scoped Target Language Compiler directives.
Begin Directive |
End Directive |
Description |
%if |
%endif |
|
%for |
%endfor |
|
%foreach |
%endforeach |
|
%roll |
%endroll |
|
%with |
%endwith |
|
%switch |
%endswitch |
|
%function |
%endfunction |
|
{ |
} |
The error is reported on the line that opens the scope and has no matching end
scope.
The construct %matlab function_name(...) construct is illegal in standalone tlc
You cannot call MATLAB from stand-alone TLC.
The FEVAL() function can accept only 2-dimensional arrays from MATLAB, not number dimensions
Return values from MATLAB can have at most two dimensions.
The FEVAL() function can accept vectors of numbers or strings only when calling MATLAB
Vectors passed to MATLAB can be numbers or strings. See FEVAL Function.
The FEVAL() function requires the name of a function to call
FEVAL
requires a function to call. This error only appears inside MATLAB.
The final argument to %roll must be a valid block scope
When using %roll
, the final argument (prior to extra user-specified arguments) must be a valid block scope. See %roll for a complete description of this command.
The first argument of a ? : operator must be a Boolean expression
The ? :
operator must have a Boolean expression as its first operand.
The first argument to GENERATE or GENERATE_TYPE must be a valid scope
When calling GENERATE
or GENERATE_TYPE
, the first argument must be a valid scope. See the GENERATE and GENERATE_TYPE functions for more information and examples.
The function name requires at least number arguments
User is passing too few arguments to a function, as in the following code:
The GENERATE function requires at least 2 arguments
When calling the GENERATE
built-in function, the first two arguments must be the block and the name of the function to call.
The GENERATE_TYPE function requires at least 3 arguments
When calling the GENERATE_TYPE
built-in function, the first three arguments must be the block, the name of the function to call, and the type.
The ISINF(), ISNAN(), ISFINITE(), REAL(), and IMAG() functions expect a real or complex valued argument
These functions expect a Real
or complex value as the input argument.
The language being implemented cannot be changed within a block template file
You cannot change the language using the %language
directive within a block template file.
The language being implemented has changed from old-language to new-language (Warning)
The language being implemented should not be changed in midstream because GENERATE
function calls that appear prior to the %language
directive may cause generate
functions to load for the prior language. Only one language directive should appear in a given file.
The left-hand side of a . operator must be a valid scope identifier
When using the .
operator, the left-hand side of the .
operator must be a valid in-scope identifier. For example,
In this code, the reference to x.y
produces this error message because x
is not defined as a scope.
The left-hand side of an assignment must be a simple expression comprised of ., [], and identifiers
Illegal left-hand side of assignment.
The number of columns specified (specified-columns) did not match the actual number of columns in all of the rows (actual-columns)
When specifying a Target Language Compiler matrix, the number of columns specified did not match the actual number of columns in the matrix. For example,
In this case, the number of columns in the declaration of the matrix (1) did not match the number of columns seen in the matrix (2). Either change the number of columns in the matrix, or change the matrix declaration.
The number of rows specified (specified-rows) did not match the actual number of rows seen in the matrix (actual-rows)
When specifying a Target Language Compiler matrix, the number of rows specified did not match the actual number of rows in the matrix. For example,
In this case, the number of rows in the declaration of the matrix (1) did not match the number of rows seen in the matrix (2). Either change the number of rows in the matrix or change the matrix declaration.
The operator_name operator only works on Boolean arguments
The &&
and ||
operators work on Boolean values only.
The operator_name operator only works on integral arguments
The &
, ^
, |
, <<
, >>
and %
operators only work on numbers.
The operator_name operator only works on numeric arguments
The arguments to the following operators both must be either Number or Real: <
, <=
, >
, >=
, -
, *
, /
. This can also happen when using + as an unary operator. In addition, the FORMAT
built-in function expects either a Number or Real argument.
The return value from the RollHeader function must be a string
When using %roll
, the RollHeader()
function specified in Roller.tlc
must return a string value. See %roll for a complete discussion of the %roll
construct.
The roll argument to %roll must be a nonempty vector of numbers or ranges
When using %roll
, the roll
vector cannot be empty and must contain numbers or ranges of numbers. See %roll for a complete discussion of the %roll
construct.
The second value in a Range must be greater than the first value
When using a range, for example, 1:10
, the lower bound was higher than the upper bound.
The specified index (index) was out of the range
0 - number-of-elements - 1
This error occurs when indexing into any nonscalar beyond the end of the variable. For example:
This example would cause this error. Remember, in the Target Language Compiler, array indices start at 0 and go to the number of elements minus 1.
The STRINGOF built-in function expects a vector of numbers as its argument
The STRINGOF
function expects a vector of numbers. The function treats each number as the ASCII value of a valid character.
The SYSNAME built-in function expects an input string of the form
<xxx>/yyy
The SYSNAME
function takes a single string of the form <xxx>/yyy
as it appears in the .rtw
file and returns a vector of two strings xxx
and yyy
. If the input argument does not match this format, it returns this error.
The threshold on a %roll statement must be a single number
When using %roll
, the roll threshold specified must be a single number. See %roll for a complete discussion of the %roll
construct.
The use of feature is being deprecated and will not be supported in future versions of TLC. See the TLC manual for alternatives.
The %define
and %generate
directives are not recommended, as they are being replaced.
The WILL_ROLL built in function expects a range vector and an integer threshold
The WILL_ROLL
function expects two arguments: a range vector and a threshold.
There are no more free contexts. Use tlc('close', HANDLE) to free up a context
The global context table has filled up while using the TLC server mode.
There was no type associated with the given block for GENERATE
The scope specified to GENERATE
must include a Type
parameter that indicates which template file should be used to generate code for the specified scope. For example,
This example produces the error message because the scope does not include the parameter Type
. See the GENERATE and GENERATE_TYPE functions for more information and examples on using the GENERATE
built-in function.
This assignment would overwrite an identifier-value pair from the RTW file. To avoid this error either qualify the left-hand side, or choose another identifier.
The user is trying to modify a field of a record in a %with
block without qualifying the left-hand side, as in this example:
TLC has leaked number symbols. You may have created a cyclic record. If this not the case then please report this leak to The MathWorks.
There has been a memory leak while running TLC. The most common cause of this is having cyclic records.
Unable to find identifier within the scope-identifier scope
The given identifier was not found in the scope specified. For example:
In this code, the reference to scope.y
produces this error message.
Unable to open %include file filename
The file included in a %include
directive was not found on the path. Either locate the file and use the -I
command line option to specify the correct directory, or move the file to a location on the current path.
Unable to open block template file filename from GENERATE or GENERATE_TYPE
When using GENERATE
, the given filename was not found on the Target Language Compiler path. You can
%generatefile
directive to specify an alternative filename for this block type that is on the path.
-I
switch.
Unable to open output file filename
Unable to open the specified output file; either an invalid filename was specified or the file was read only.
Undefined identifier identifier_name
The identifier specified in this expression was undefined.
Unknown type "type" in CAST expression
When calling the CAST
built-in function, the type must be one of the valid Target Language Compiler types found in the Target Language Values table.
Unrecognized command line switch passed to string: switch
When querying the current state of a switch, the switch specified was not recognized.
Unrecognized directive "directive-name" seen
An illegal %
directive was encountered. The valid directives are shown below.
Unrecognized type "output-type" for function
The function type modifier was not Output
or void
. For functions that do not produce output, the default without a type modifier indicates that the function should produce no output.
Unterminated multiline comment.
A multiline (i.e. /% %/) comment has no terminator, as in the following code:
Unterminated string
A string must be closed prior to the end of an expansion directive or the end of a line.
Usage: tlc [options] file
A command line problem has occurred. The error message contains a list of all of the available options.
Use of feature incurs a performance hit, please see TLC manual for possible workarounds.
The %undef
and expansion (i.e. %<expr>
) features may cause performance hits.
Value of specified_type type cannot be compared
The specified type (i.e., scope) cannot be compared.
Values of specified_type type cannot be expanded
The specified type cannot be used on an expansion directive. Files and scopes cannot be expanded. This can also happen when expanding a function without any arguments. If you use
call it with the appropriate arguments.
Values of type Special, Macro Expansion, Function, File, Full Identifier, and Index cannot be converted to MATLAB variables
The specified type cannot be converted to MATLAB variables.
When appending to a buffer stream, the variable must be a string
You can specify the append
option for a buffer stream only if the variable currently exists as a string. Do not use the append
option if the variable does not exist or is not a string. This example produces this error.
![]() | Formatting Error Messages | TLC Function Library Error Messages | ![]() |