coder.dataAlignment - Specify data alignment for global or entry-point/exported
function input and output arguments - MATLAB (original) (raw)
Main Content
Specify data alignment for global or entry-point/exported function input and output arguments
Syntax
Description
coder.dataAlignment(['varName'](#bvn0llo-1-varName),[align_value](#bvn0llo-1-align%5Fvalue))
specifies data alignment in MATLABĀ® code for the variable (varName
), which is imported data or global (exported) data. The code generator aligns the imported or exported data to the alignment boundary (align_value
).
Examples
An example function that specifies data alignment for imported data.
function y = importedDataExampleFun(x1,x2)
coder.dataAlignment('x1',16); % Specifies information coder.dataAlignment('x2',16); % Specifies information coder.dataAlignment('y',16); % Specifies information
y = x1 + x2;
end
An example function that specifies data alignment for exported data.
function a = exportedDataExampleFun(b)
global z; coder.dataAlignment('z',8);
a = b + z;
end
Input Arguments
The varName
is a character array of the variable name that requires alignment information specification.
The alignvalue
is an integer number which should be a power of 2. This number specifies the power-of-2 byte alignment boundary.
Limitations
Limitations on variables supported by coder.dataAlignment
directive:
- Only use
coder.dataAlignment
to specify alignment information for function inputs, outputs, and global variables. coder.dataAlignment
supports only matrix types, including matrix of complex types.- For exported custom storage classes (CSCs),
coder.dataAlignment
supports onlyExportedGlobal
. You can specify alignment information for any imported CSCs. - The code generator ignores
coder.dataAlignment
for non-ERT or non-ERT derived system target files. - Global variables tagged using the
coder.dataAlignment
directive from within a MATLAB function block are ignored. Set the alignment value on the corresponding Data Store Memory. - The
coder.dataAlignment
function generates an error if a code replacement library is not specified. For more information, see Provide Data Alignment Specifications for Compilers.
Tips
- To prevent inlining a function containing an aligned variable in the generated code, a best practice is to call
coder.inline('never')
in your code.
Extended Capabilities
Version History
Introduced in R2017a