Erscheinungsbild des Codes
Modifizieren Sie Konfigurationsparameter, die Aspekte des Code-Erscheinungsbilds und -Stils regeln, wie Kommentarstil, Datentyp-Castingmodus und Einrückstil. Parameter, die das Erscheinungsbild und den Stil des Codes regeln, finden Sie unter Embedded Coder Capabilities for Code Generation from MATLAB Code.
Sie können eine CGT-Datei (Code Generation Template) anpassen, um benutzerdefinierte Banner und Trailer sowie Kommentare vor Codeabschnitten zu erstellen. Siehe Generate Custom File and Function Banners for C/C++ Code.
Funktionen
coder.setupMISRAConfig | Configure parameters to improve generated code compliance with MISRA and AUTOSAR guidelines |
Klassen
coder.MATLABCodeTemplate | Represent code generation template for MATLAB Coder |
Themen
Code-Kommentare
- Specify Comment Style for C/C++ Code
Generate single-line or multiline comments in C/C++ code generated from MATLAB® code.
Identifikatoren
- Customize Generated Identifiers
Specify format of identifiers in C/C++ code generated from MATLAB code.
Dateinamen
- Customize C/C++ File Names Generated from MATLAB Code
Specify format of C/C++ file names generated from MATLAB code.
Codestil
- Controlling C Code Style
Generateswitch-casestatements instead ofif-elseif-elsestatements 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.
Steuern von Datentypnamen
- 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.
Codevorlagen
- 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.
Fehlersuche
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.