coder.ceval
呼叫外部C / C ++函数
Syntax
coder.ceval(cfun_name)
coder.ceval(cfun_name,cfun_arguments)
coder.ceval('-global',cfun_name)
coder.ceval('-global',cfun_name,cfun_arguments)
coder.ceval('-layout:rowMajor',cfun_name,cfun_arguments)
coder.ceval('-layout:columnMajor',cfun_name,cfun_arguments)
coder.ceval('-layout:any',cfun_name,cfun_arguments)
cfun_return = coder.ceval(___)
描述
coder.ceval(
executes the external C/C++ function specified bycfun_name
)cfun_name
。定义cfun_name
在外部C / C ++源文件或库中。为代码生成器提供外部源,库和标头文件。
coder.ceval(
executescfun_name
,cfun_arguments
)cfun_name
with argumentscfun_arguments
。cfun_arguments
is a comma-separated list of input arguments in the order thatcfun_name
需要。
默认,coder.ceval
passes arguments by value to the C/C++ function whenever C/C++ supports passing arguments by value. To makecoder.ceval
pass arguments by reference, use the constructscoder.ref
,coder.rref
, andcoder.wref
。If C/C++ does not support passing arguments by value, for example, if the argument is an array,coder.ceval
passes arguments by reference. If you do not usecoder.ref
,coder.rref
orcoder.wref
, a copy of the argument can appear in the generated code to enforce MATLAB®semantics for arrays.
coder.ceval(
executes'-global'
,cfun_name
)cfun_name
并表示cfun_name
uses one or more MATLAB global variables. The code generator can then produce code that is consistent with this global variable usage.
coder.ceval(
executes'-global'
,cfun_name
,cfun_arguments
)cfun_name
with argumentscfun_arguments
并表示cfun_name
uses one or more MATLAB global variables.
coder.ceval(
executes'-layout:rowmajor'
,cfun_name
,cfun_arguments
)cfun_name
with argumentscfun_arguments
and passes data stored in row-major layout. When called from a function that uses column-major layout, the code generator converts inputs to row-major layout and converts outputs back to column-major layout. For a shorter syntax, usecoder.ceval('-row',...)
。
coder.ceval(
executes'-layout:columnMajor'
,cfun_name
,cfun_arguments
)cfun_name
with argumentscfun_arguments
并通过数据存储在列为主的布局。当n called from a function that uses row-major layout, the code generator converts inputs to column-major layout and converts outputs back to row-major layout. For a shorter syntax, usecoder.ceval('-col',...)
。
coder.ceval(
executes'-layout:任何'
,cfun_name
,cfun_arguments
)cfun_name
with argumentscfun_arguments
and passes data with its current array layout, even when array layouts do not match. The code generator does not convert the array layout of the input or output data.
cfun_return = coder.ceval(___)
executescfun_name
and returns a single scalar value,cfun_return
, corresponding to the value that the C/C++ function returns in thereturn
statement. To be consistent with C/C++,coder.ceval
can return only a scalar value. It cannot return an array. Use this option with any of the input argument combinations in the previous syntaxes.
例子
Input Arguments
Limitations
You cannot use
coder.ceval
on functions that you declare extrinsic withcoder.extrinsic
。当n the LCC compiler creates a library, it adds a leading underscore to the library function names. If the compiler for the library was LCC and your code generation compiler is not LCC, you must add the leading underscore to the function name, for example,
coder.ceval('_mylibfun')
。If the compiler for a library was not LCC, you cannot use LCC to generate code from MATLAB code that calls functions from that library. Those library function names do not have the leading underscore that the LCC compiler requires.If a property has a get method, a set method, or validators, or is a System object™ property with certain attributes, then you cannot pass the property by reference to an external function. SeePassing By Reference Not Supported for Some Properties。
提示
对于代码生成,请在主叫之前
coder.ceval
,您必须指定返回值和输出参数的类型,大小和复杂性数据类型。Use
coder.ceval
only in MATLAB for code generation.coder.ceval
generates an error in uncompiled MATLAB code. To determine if a MATLAB function is executing in MATLAB, usecoder.target
。如果函数执行在MATLAB调用马铃薯草version of the C/C++ function.
See Also
Codegen.
|coder.columnMajor
|coder.extrinsic
|coder.opaque
|coder.ref
|coder.rowMajor
|coder.rref
|coder.target
|coder.updatebuildinfo.
|coder.wref