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)