Structures
MATLAB® Coder™ supports code generation for structures with a set of restrictions on the operations, the properties of values of scalar structures, and the structure arrays. You can generate code for scalar structures as well as structure arrays. Adhere to restrictions for indexing and assigning values to substructures and fields. Structure arguments are passed by reference or by value in generated code.
Functions
coder.cstructname | Name generated or externally defined structure type in C or C++ code |
Topics
- Structure Limitations for Code Generation
Adhere to code generation restrictions for structures.
- Generate Standalone C Code for Array of Structures
Generate code for a MATLAB function that uses a structure array.
- Pass Structure Arguments by Reference or by Value in Standalone Code
Control whether structure arguments are passed by reference or by value.
- Name C Structure Type to Use with Global Structure Variable
Use
coder.cstructnameto define a type object for a global structure. - Synchronize MATLAB Structure with Structure Type in Generated Code
Use a constructor function and
coder.OutputTypeto generate a structure type that you can use in MATLAB functions and the generated code.
Troubleshooting
Resolve Error: Variables Must Be Fully Defined Before Use
Troubleshoot code generation error when variables are not defined before use.