04-18-2018 01:23 AM
I have function written in dll (c++) as:
unsigned long myFunction( myStruct data );
struct myStruct
{
uint32_t parameter1
uint32_t parameter2
};
My quiestion is: Is it ok to call myFunction like this in Labview:
uint32_t myFunction( uint64_t data);
Solved! Go to Solution.
04-18-2018 01:33 AM - edited 04-18-2018 01:33 AM
04-18-2018 04:22 AM
Yes, I agree, but what about my idea? Is LV interpreting this the same as cluster of 2 32bit ints?
04-18-2018 04:59 AM - edited 04-18-2018 05:02 AM
@Skoda3 wrote:
Yes, I agree, but what about my idea? Is LV interpreting this the same as cluster of 2 32bit ints?
Yes, but you need to be careful about endianess. On x86 (all current LabVIEW platforms except the RIO ARM and vxWorks targets) LabVIEW uses little endian format. That means that the lower significant 32 bit value is also the first value in your cluster. For Big Endian platforms you would have to put the first value in your cluster into the most significant 32 bit part of your 64 bit value.
Basically:
And it is not really about what LabVIEW interpretes here, as LabVIEW interpretes nothing in this case. It is about what your DLL expects and that is defined by what the used C compiler used to create your DLL did in terms of aligning the parameters on the stack in a specific way.
This is special since the parameter seems to be declared to be passed by value (which is quite unusual for structs). If it was declared to be passed by pointer you could simply configure the CLN parameter to be Adapt to Type and wire the cluster to it.