libpointer
Creates an C pointer object usuable in Nelson.
📝Syntax
ptr = libpointer()
ptr = libpointer(datatype)
ptr = libpointer(datatype, value)
📥Input Arguments
Parameter Description
datatype a string: data type.
value a nelson variable compatible with datatype.
📤Output Arguments
Parameter Description
ptr a libpointer handle.
📄Description

This is an advanced feature to manipulate C pointers.

ptr = libpointer() creates an NULL pointer.

💡Examples
p = libpointer('int8Ptr', int8([3 4]));
p.isNull()
p.DataType
p.Value
NLSDYNAMIC_LINK_IMPEXP double *multiplicationDoubleByReference(double *x)
{
    *x *= 2;
    return x;
}
x = 133.3;
xPtr = libpointer('doublePtr', x);
path_ref = modulepath('dynamic_link', 'builtin');
lib = dlopen(path_ref);
f = dlsym(lib, 'multiplicationDoubleByReference', 'libpointer', {'doublePtr'});
[r1, r2] = dlcall(f, xPtr);
r2
% r1 is an libpointer of type '' (voidPointer) and it need to be change type and size.
r1.setdatatype('doublePtr');
r1.reshape(1, 1);
get(r1)
🔗See Also
C/Nelson equivalent data typesisNulllibpointer.reshapelibpointer.setdatatype
🕔Version History
Version Description
1.0.0 initial version
Edit this page on GitHub