06-18-2024 02:10 AM - edited 06-18-2024 02:30 AM
Hi everyone,
I'm new to LabVIEW, so I apologize in advance for any mistakes or confusion in my question.
I'm trying to pass arrays or clusters from my DLL to LabVIEW. Here's the solution I've implemented:
typedef struct {
int32_t dimSize;
int32_t elt[1];
} Array1DInt;
typedef Array1DInt** A1DDhandle;
void __declspec(dllexport) getArray1D(A1DDhandle arr)
{
int i; // Allocate memory for 4 elements DSSetHandleSize
(arr, sizeof(int32_t) + 4 * sizeof(int32_t));
(*arr)->dimSize = 4;
for (i = 0; i < 4; i++)
{ (*arr)->elt[i] = (i + 1) + 420; }
}
I gathered this code from various YouTube videos and forum entries, but I'd like to understand it better. Specifically, I'm looking for proper documentation for the functions from extcode.h
. I couldn't find anything useful.
Can someone point me to detailed documentation ?
Thanks in advance for your help!
Solved! Go to Solution.
06-18-2024 04:23 AM
Is this detailed enough DSSetHandleSize? In your case you can use NumericArrayResize, so that you do not need to take the size part into account.
There is an example shipping with LabVIEW at LabVIEW 20XX\examples\Connectivity\Libraries and Executables\External Code (DLL) Execution.vi
Source C Files\LVLStrHandle.c contains an example using DSSetHandleSize, CLUSTERComplex.c contains an example using NumericArrayResize and shows how to handle dynamically sized data types in a cluster.