Code Appearance
Modify configuration parameters that control aspects of code appearance and style, such as comment style, data type casting mode, and indentation style. For parameters that control code appearance and style, see Embedded Coder Capabilities for Code Generation from MATLAB Code.
Generate custom banners and trailers, and comments, before code sections by customizing a code generation template (CGT) file. See Generate Custom File and Function Banners for C/C++ Code.
Functions
coder.setupMISRAConfig | Configure parameters to improve generated code compliance with MISRA and AUTOSAR guidelines |
Classes
coder.MATLABCodeTemplate | Represent code generation template for MATLAB Coder |
Topics
Code Comments
- Specify Comment Style for C/C++ Code
Generate single-line or multiline comments in C/C++ code generated from MATLAB® code.
Identifiers
- Customize Generated Identifiers
Specify format of identifiers in C/C++ code generated from MATLAB code.
File Names
- Customize C/C++ File Names Generated from MATLAB Code
Specify format of C/C++ file names generated from MATLAB code.
Code Style
- Controlling C Code Style
Generateswitch-case
statements instead ofif-elseif-else
statements in C/C++ code generated from MATLAB code. - Specify Indent Style for C/C++ Code
Use K&R or Allman indent style in C/C++ code generated from MATLAB code. - Control Signed Left Shifts in Generated Code
Control whether the code generator replaces multiplications by powers of two with signed, left bitwise shifts in code generated from MATLAB code. - Control Data Type Casts in Generated Code
Specify the data type casting mode, that is, default mode, standards compliant mode, or explicit mode, in C/C++ code generated from MATLAB code. - Generate C/C++ Code with Improved MISRA and AUTOSAR Compliance
Configure code generation parameters to increase the MISRA™ and AUTOSAR compliance of the generated C/C++ code.
Control Data Type Names
- Customize Data Type Replacement
Specify custom data type names in C/C++ code generated from MATLAB code. - Import Custom Data Type Definitions from External Header Files
Specify header file names, which contain custom type definitions, that you want to import.
Code Templates
- Code Generation Template Files for MATLAB Code
A CGT file specifies file and function banners, and comments before code sections in C/C++ code generated from MATLAB code. - Generate Custom File and Function Banners for C/C++ Code
Customize a CGT file to generate your own file and function banners in C/C++ code generated from MATLAB code.
Troubleshooting
MATLAB Code Patterns That Require a Nonempty Initialize Function in Generated Code
Code generation fails when you choose not to include the initialize function, even though the custom code for the generated initialize function is empty.