User`s guide
Including M-File Information in Compiler Output
5-43
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. (Note that several lines have been truncated for readability.)
#line 1 "D:\\work\\hello.m" /* Line 1 */
static void Mhello(void) {
#line 1 "D:\\work\\hello.m" /* Line 1 */
mclMlineEnterFunction("D:\\work\\hello.m", "hello")
#line 1 "D:\\work\\hello.m" /* Line 1 */
mexLocalFunctionTable save_local_function_table_ = -->
#line 1 "D:\\work\\hello.m" /* Line 1 */
mxArray * ans = NULL;
/*
* % This is the hello, world function written in M code
* fprintf(1,'Hello, World\n' );
*/
#line 3 "D:\\work\\hello.m" /* Line 3 */
mclMline(3);
#line 3 "D:\\work\\hello.m" /* Line 3 */
mclAssignAns(&ans, mlfNFprintf(0, mlfScalar(1), mxCreateString("Hello,-->
#line 3 "D:\\work\\hello.m" /* Line 3 */
mxDestroyArray(ans);
#line 3 "D:\\work\\hello.m" /* Line 3 */
mclSetCurrentLocalFunctionTable(save_local_function_table_);
#line 3 "D:\\work\\hello.m" /* Line 3 */
mclMlineExitFunction();
#line 3 "D:\\work\\hello.m" /* Line 3 */
}
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 3 points to lines in the C code that were produced by line 3 of the M-file, or
fprintf(1,'Hello, World\n' );