I'm using LV 2018 (x64) and I'm trying to call DLL function.
How do you send the reference to the structure to the DLL instead of pointer to the structure?
This is the function description and example:
This is the LV program and cluster (structure) declaration.
The problem is, when I try to execute this VI, I get a memory management error and the LV crashes. How do you send the reference to the structure to the DLL instead of pointer to the structure?
I have checked that the cluster data is in the same order as the structure in DLL. The data types are all correct (signed I32). Is it possible that I have mismatching memory alignment between LV and DLL?. How to check this? The DLL is precompiled and I cannot edit it.
Any help would be appreciated.
Solved! Go to Solution.
Your problem is not to pass a reference to the structure instead of a pointer. Those two are in fact synonymous to each other, at least in terms of C programming which the DLL calls are, so there is no difference between the two. If you would talk about C++ there are semantic differences but technically in terms of what the compiler generates it is still the same.
Your problem is that your structure/cluster should contain a fixed size array. A C compiler does not include that in a structure as a pointer and even if it did, a LabVIEW array is NOT a C array pointer.
Luckily for you there is a pretty simple solution for you. Replace the array in your cluster with another cluster that contains 32 Int32 numbers. Now the LabVIEW cluster is equivalent in memory layout to the C structure that function expects.
Thank you for your explanation and solution!
I have changed my program according to you, and it works now!
Thank you very much