MATLAB® Coder™ resolves MATLAB functions by searching first on the code generation path and then on the MATLAB path. The code generation path contains the current folder and the code generation libraries. By default, unless MATLAB Coder determines that a function should be extrinsic or you explicitly declare the function to be extrinsic, MATLAB Coder tries to compile and generate code for functions it finds on the path. MATLAB Coder does not compile extrinsic functions, but rather dispatches them to MATLAB for execution. See Resolution of Function Calls for Code Generation.
If you want to integrate custom code — such as source, header, and library files — with the generated code, you can specify additional folder to search. The following table describes how to specify these search paths. The path should not contain:
Spaces (Spaces can lead to code generation failures in certain operating system configurations)
Non-7-bit ASCII characters, such as Japanese characters
|To specify additional folders||Do this|
|Using the MATLAB Coder app||
|At the command line||Use the |
MATLAB Coder enforces naming conventions for MATLAB functions and generated files.
Coder reserves the prefix
eml for global C/C++ functions
and variables in generated code. For example, MATLAB for code generation run-time library function names begin with the
emlrt, such as
emlrtCallMATLAB. To avoid
naming conflicts, do not name C/C++ functions or primary MATLAB functions with the prefix
MATLAB Coder software reserves certain words for its own use as keywords of the generated code language. MATLAB Coder keywords are reserved for use internal to MATLAB Coder software and should not be used in MATLAB code as identifiers or function names. C reserved keywords should also not be used in MATLAB code as identifiers or function names. If your MATLAB code contains reserved keywords that the code generator cannot rename, the code generation build does not complete and an error message is displayed. To address this error, modify your code to use identifiers or names that are not reserved.
If you are generating C++ code using the MATLAB Coder software, in addition, your MATLAB code must not contain the C++ Reserved Keywords.
C Reserved Keywords
C++ Reserved Keywords
Reserved Keywords for Code Generation
MATLAB Coder Code Replacement Library Keywords. The list of code replacement library (CRL) reserved keywords for your development environment varies depending on which CRLs currently are registered. Beyond the default ANSI®, ISO®, and GNU® CRLs provided with MATLAB Coder software, additional CRLs might be registered and available for use if you have installed other products that provide CRLs (for example, a target product), or if you have used Embedded Coder® APIs to create and register custom CRLs.
To generate a list of reserved keywords for the CRLs currently registered in your environment, use the following MATLAB function:
crl_ids = RTW.TargetRegistry.getInstance.getTflReservedIdentifiers()
This function returns a cell array of character vectors that contain CRL keywords. Specifying the return argument is optional.
To list the CRLs currently registered in your environment, use the
To generate a list of reserved keywords for the CRL that you are using to generate code, call the function passing the name of the CRL as displayed in the Code replacement library menu on the Code Generation > Interface pane of the Configuration Parameters dialog box. For example,
crl_ids = RTW.TargetRegistry.getInstance.getTflReservedIdentifiers('GNU99 (GNU)')
Here is a partial example of the function output:
>> crl_ids = RTW.TargetRegistry.getInstance.getTflReservedIdentifiers('GNU99 (GNU)') crl_ids = 'exp10' 'exp10f' 'acosf' 'acoshf' 'asinf' 'asinhf' 'atanf' 'atanhf' ... 'rt_lu_cplx' 'rt_lu_cplx_sgl' 'rt_lu_real' 'rt_lu_real_sgl' 'rt_mod_boolean' 'rt_rem_boolean' 'strcpy' 'utAssert'
Some of the returned keywords appear with the suffix
into the suffix
_snf only if nonfinite numbers are
supported. For example,
'rt_atan2_snf' if nonfinite numbers are supported and
'rt_atan2' if nonfinite numbers are not supported. As a
precaution, you should treat both forms of the keyword as reserved.
The following table describes how MATLAB Coder names generated files. MATLAB Coder follows MATLAB conventions by providing platform-specific extensions for MEX files.
|Platform||MEX File Extension||MATLAB Coder Extension for Static Library||MATLAB Coder Extension for Shared Library||MATLAB Coder Executable Extension|
Also, generates an import library with a