coder.cstructname(var,'structName')
coder.cstructname(var,'structName','extern')
coder.cstructname(var,'structName','extern',Name,Value)
newt =
coder.cstructname(t,'structName')
newt =
coder.cstructname(t,'structName','extern')
newt =
coder.cstructname(t,'structName','extern',Name,Value)
coder.cstructname(
specifies
the name of the structure type that represents var
,'structName
')var
in
the generated C/C++ code. var
is a structure
or cell array variable. structName
is the name
for the structure type in the generated code. Use this syntax in a function from
which you generate code. Call coder.cstructname
before
the first use of the variable. If var
is a cell
array element, call coder.cstructname
after the
first assignment to the element.
coder.cstructname(
declares
an externally defined structure. It does not generate the definition
of the structure type. Provide the definition in a custom include
file.var
,'structName
','extern')
coder.cstructname(
uses
additional options specified by one or more var
,'structName
','extern',Name,Value
)Name,Value
pair
arguments.
returns
a copy of the type object specified by newt
=
coder.cstructname(t
,'structName
')t
. The
copy specifies the name structName
to use for
the structure type that represents t
in the generated
code. t
is a coder.StructType
object
or a coder.CellType
object. Use this syntax to create
a type that you use with the codegen
-args
option.
You cannot use this syntax in a function from which you generate code.
returns
a newt
=
coder.cstructname(t
,'structName
','extern')coder.type
that uses an externally defined structure.
Provide the structure definition in a custom include file.
uses
additional options specified by one or more newt
=
coder.cstructname(t
,'structName
','extern',Name,Value
)Name,Value
pair
arguments.
You cannot use coder.cstructname
with
global variables.
If var
is a cell array or t
is a coder.CellType
object, the
field names of externally defined structures must be f1
, f2
,
and so on.
If var
is a cell array element,
call coder.cstructname
after the first assignment
to the element. For example:
... x = cell(2,2); x{1} = struct('a', 3); coder.cstructname(x{1}, 'mytype'); ...
The code generator represents a heterogeneous cell
array as a structure in the generated C/C++ code. To specify the name
of the generated structure type, use coder.cstructname
.
Using coder.cstructname
with
a homogeneous coder.CellType
object t
makes
the returned object heterogeneous unless t
is permanently
homogeneous. If the makeHomogeneous
method created t
or
if t
is variable size,t
is permanently
homogeneous.
When used with a coder.CellType
object, coder.cstructname
creates
a coder.CellType
object that is permanently heterogeneous.
In a function from
which you generate code, using coder.cstructname
with
a cell array variable makes the cell array heterogeneous. Unless the
cell array type is permanently set to homogeneous, you can use coder.cstructname
with
an entry-point function input that is a cell array.
To use coder.cstructname
on arrays,
use single indexing. For example, you cannot use coder.cstructname(x(1,2))
.
Instead, use single indexing, for example coder.cstructname(x(n))
.
If you use coder.cstructname
on
an array, it sets the name of the base type of the array, not the
name of the array. Therefore, you cannot use coder.cstructname
on
the base element and then on the array. For example, the following
code does not work. The second coder.cstructname
attempts
to set the name of the base type to myStructArrayName
,
which conflicts with the previous coder.cstructname
, myStructName
.
% Define scalar structure with field a myStruct = struct('a', 0); coder.cstructname(myStruct,'myStructName'); % Define array of structure with field a myStructArray = repmat(myStruct,k,n); coder.cstructname(myStructArray,'myStructArrayName');
If you are using custom structure types, specify the
name of the header file that includes the external definition of the
structure. Use the HeaderFile
input argument.
If you have an Embedded Coder® license and use
Code Replacement Libraries (CRLs), the CRLs provide the ability to
align data objects passed into a replacement function to a specified
boundary. To take advantage of target-specific function implementations
that require data to be aligned, use the Alignment
input
argument.
You can also use coder.cstructname
to
assign a name to a substructure, which is a structure that appears
as a field of another structure. For more information, see Assign a Name to a SubStructure.
|
The name of the structure type in the generated code. |
|
|
|
Structure or cell array variable. |
Specify optional comma-separated pairs of Name,Value
arguments.
Name
is the argument
name and Value
is the corresponding
value. Name
must appear
inside single quotes (' '
).
You can specify several name and value pair
arguments in any order as Name1,Value1,...,NameN,ValueN
.
|
The run-time memory alignment of structures of this type in bytes. If you have an Embedded Coder license and use Code Replacement Libraries (CRLs), the CRLs provide the ability to align data objects passed into a replacement function to a specified boundary. This capability allows you to take advantage of target-specific function implementations that require data to be aligned. By default, the structure is not aligned on a specific boundary. Hence it is not matched by CRL functions that require alignment.
Default: -1 |
|
Name of the header file that contains the external definition
of the structure, for example, By default, the generated code contains Must be a non-empty character vector. |
|
|
codegen
| coder.CellType
| coder.ceval
| coder.rref
| coder.StructType