Specify Comment Style for C/C++ Code
If you have an Embedded Coder®, you can specify the comment style for C/C++ code generated from MATLAB® code. Specify single-line style to generate single-line comments preceded by
//
. Specify multiline style to generate single-line or multiline comments
delimited by /*
and */
. Single-line style is the default
for C++ code generation. Multiline style is the default for C code generation. For C code
generation, select single-line comment style only if your compiler supports it.
Specify Comment Style Using the MATLAB Coder App
On the Generate Code page, to open the Generate dialog box, click the Generate arrow .
Set Build type to one of the following:
Source Code
Static Library (.lib)
Dynamic Library (.dll)
Executable (.exe)
Click More Settings.
On the Code Appearance tab, select the Include comments check box if it is not already selected. By default, the Include comments check box is selected.
Set Comment Style to one of the following options.
Value Description Auto(Use standard comment style of the target language)
For C, generate multiline comments. For C++, generate single-line comments. (default) Single-line (Use C++-style comments)
Generate single-line comments preceded by //
.Multi-line (Use C-style comments)
Generate single-line or multiline comments delimited by /*
and*/
.
Specify Comment Style Using the Command-Line Interface
Create a code configuration object for C/C++ code generation. For example, create a configuration object for C/C++ static library generation:
cfg = coder.config('lib','ecoder',true);
Set the
CommentStyle
property to one of the following values:Value Description 'Auto'
For C, generate multiline comments. For C++, generate single-line comments. (default) 'Single-line'
Generate single-line comments preceded by //
.'Multi-line'
Generate single-line or multiline comments delimited by /*
and*/
.For example, this code sets the comment style to single-line style:
cfg.CommentStyle='Single-line';