LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

|How to pass LV Cluster containing Cluster to Dll?



@tbob wrote:

I wasn't talking about flat data, I was comparing the way Labview stores a cluster to the way C stores a structure.  What I mean is that Labview may store the number of elements first, then the elements, and so on.  I am not quite sure exactly how LV does it but I do know that C stores structures differently.  If it did, it would be quite easy to pass a Labview cluster to a C structure.

Whatever the case, I am able to pass LV clusters successfully to and from C structures in a DLL using the methods I described earlier, without use a wrapper.  Again it may depend on the DLL and how it was written.


In your explanation you dont make the full distinction between a few things. In C there is a difference between a fixed size string or array inside a structure and a pointer to a string or array. The fixed size strings or arrays are simply inlined whereas the pointer accesses a separate memory area to that of the structure. The first can be easily simulated in LabVIEW with creating a cluster of a fixed number of elements inside the main cluster as has been shown by you. The second is not easily handled without an external wrapper library.

While the WinAPI often uses the fixed size (inlined) strings, this is just a convention. It is easier in terms of memory management between caller and callee, but it has one big drawback and that is that extending the size of such embedded strings usually breaks binary compatibility of the API. And considering that we once only used 8+3 characters for file names one can see where fixed size strings can lead too 😉

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 11 of 12
(751 Views)
I guess I didn't see the part about passing variable size strings or arrays in the original question.  Of course mine is fixed size or it wouldn't work.  Sorry I didn't make that distinction.
- tbob

Inventor of the WORM Global
0 Kudos
Message 12 of 12
(741 Views)