define
R2026bDescription
define(
defines or customizes an output argument with one or more name-value arguments.outargDef,Name=Value)
Examples
MATLAB cannot determine whether a char const*
parameter represents a text string or a character buffer. To define an output argument as
a null-terminated C string, set MATLABType to
"string" and Size to
"nullTerminated".
The documentation for this function getMessage specifies the
output argument as a null-terminated C string.
const char* getMessage();Publish an interface libname containing
getMessage. The function has no input arguments and one output
argument. The status of the function is Incomplete.
fcn = idef.findFunction("getMessage")fcn =
FunctionDefinition with properties:
CPPName: "getMessage"
MATLABName: "clib.libname.getMessage"
Overloaded: false
CPPSignature: "char const * getMessage()"
MATLABSignature: <Define incomplete output to see the MATLAB signature.>
CPPInputs: [1×0 clibgen.api.InputArgumentDefinition]
CPPOutput: [1×1 clibgen.api.OutputArgumentDefinition]
Status: Incomplete
Included: false
Show all properties
Display information about the output argument.
fcn.CPPOutput
ans =
OutputArgumentDefinition with properties:
Name: "RetVal"
CPPType: "char const *"
MATLABType: <undefined>
Size: <undefined>
Status: Incomplete
To define RetVal as a null-terminated C string, set
MATLABType to "string" and
Size to "nullTerminated".
arg = fcn.CPPOutput; define(arg,MATLABType="string",Size="nullTerminated",Description="Message returned by the library") fcn
fcn =
FunctionDefinition with properties:
CPPName: "getMessage"
MATLABName: "clib.libname.getMessage"
Overloaded: false
CPPSignature: "char const * getMessage()"
MATLABSignature: RetVal = clib.libname.getMessage()
CPPInputs: [1×0 clibgen.api.InputArgumentDefinition]
CPPOutput: [1×1 clibgen.api.OutputArgumentDefinition]
Status: Complete
Included: true
Show all properties
The getMessage function is now included in the interface.
In MATLAB, call clib.libname.getMessage.
fcn.MATLABSignature
ans =
"MATLAB signature for FunctionDefinition
Maps C++ signature:
char const * getMessage()
to MATLAB as:
RetVal = clib.libname.getMessage()
Output Arguments
RetVal string
"
For example:
msg = clib.libname.getMessage
Input Arguments
Argument definition, specified as a clibgen.api.OutputArgumentDefinition object.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: define(outArg,MATLABType="string",Size="nullTerminated")
MATLAB® type for argument, specified as a string scalar.
Use "struct" for data types that satisfy the requirements
described in Supported struct Types.
Dimensions of array data, specified as a numeric vector, string vector, cell
array, or "nullTerminated". MATLAB uses this value to determine the
number of elements in the pointer data returned from the function. For example:
Size = 1, the pointer refers to a single element.
Size = 5, the pointer refers to an array of five elements.
Size =
"len", the number of elements in the array equals the value of the parameter"len".Size =
["m","n"], the pointer refers to a matrix with the number of elements in each dimension equal to the values of the parameters"m"and"n".Size =
"nullTerminated", the pointer refers to a C++ string.
Argument description that describes the output argument for the end user, specified as a string scalar.
Version History
Introduced in R2026b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)