MATLAB Compiler | ![]() ![]() |
Controlling #line Directives in Output Code
#line
preprocessing directives inform a C/C++ compiler that the C/C++ code was generated by another tool (MATLAB Compiler) and they identify the correspondence between the generated code and the original source code (M-file). You can use the #line
directives to help debug your M-file(s). Most C language debuggers can display your M-file source code. These debuggers allow you to set breakpoints, single step, and so on at the M-file code level when you use the #line
directives.
Use the line:setting
option to include #line
preprocessor directives in your generated C or C++ output. The possible values for setting are:
Not specifying any line
setting uses the default of off
, which does not include any #line
preprocessor directives in the generated C/C++ source.
Note
When using the #line directive, the page-width directive is disabled in order to make the code work properly with the C debugger.
|
Include #line Directives
To include #line
directives in your generated C or C++ code, use
mcc -A line:on ...
The Hello, World example produces the following code segment when this option is selected.
In this example, Line 1 points to lines in the generated C code that were produced by line 1 from the M-file, that is
function hello
Line 5 points to lines in the C code that were produced by line 5 of the M-file, or
fprintf(1,'Hello, World\n' );
![]() | Controlling Comments in Output Code | Controlling Information in Run-Time Errors | ![]() |