Class: clibgen.FunctionDefinition
Package: clibgen

Add input argument definition for C++ package function




defineArgument(funcDef,argName,mltype) adds an input argument definition for a C++ package function.

defineArgument(funcDef,argName,mltype,direction) defines whether argument is input, output, or both.

defineArgument(funcDef,argName,mltype,direction,shape) provides information about data dimensions.

defineArgument(___,argDesc) adds an argument description, and can include any of the input parameters in previous syntaxes.

defineArgument(___,'ReleaseOnCall',ownership) determines memory ownership of the argument.

Input Arguments

expand all

Function definition, specified as a clibgen.FunctionDefinition object.

C++ argument name, specified as a string scalar or a character vector.

MATLAB® type, specified as a string scalar or a character vector.

Argument type, specified as "input" for an input argument, "output" for an output argument, or "inputoutput" for both an input and an output argument.

Dimension definition used by MATLAB to define data dimensions, specified as a string vector, scalar text, positive integer vector, "nullTerminated", or a cell array. For a cell array, the elements are a combination of scalar text and scalar positive integers.

If you can define the argument dimension as a fixed scalar value, then enter a number, such as 5.

If the dimension is defined by another argument, then enter the argument name as a string. For example, consider the following C++ signature. If argument len defines the length of data, then the value of shape is "len".

myFunc(const int *data, int len)

If the size of an argument is defined by an array, then the value of shape is one of the following:

  • 1

  • Fixed dimensions: Enter a numerical array, such as [5,2].

  • Variable dimensions: Enter a string array of parameter names, such as ["row","col"]

If the C++ type for the argument is a string, then use these options to choose values for the mltype and shape arguments.

C++ TypemltypeOptions for shape
char *


Scalar value
Array of scalar values

const char *


Character vector



For more information, see MATLAB to C++ Data Type Mapping.

C++ argument description, specified as a string scalar or a character vector.

Transfer memory ownership of argument, specified by true or false and used with the 'ReleaseOnCall' parameter. MATLAB owns memory that is allocated as a pointer or a reference for an input argument. The C++ library should not free this memory. To change this behavior for a non-const argument, set the 'ReleaseOnCall' parameter to true. The 'ReleaseOnCall' parameter is not supported for const arguments.

If 'ReleaseOnCall' is not specified, then ownership is false.

Example: 'ReleaseOnCall',true

Data Types: logical

Introduced in R2019a