LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing two 32 bit integers as one 64 bit integer in dll function

Solved!
Go to solution

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);

 

 

 

0 Kudos
Message 1 of 4
(3,176 Views)

Hi Skoda,

 

is a struct not just the same as a cluster?

So I would try a cluster of two U32 values…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(3,170 Views)

Yes, I agree, but what about my idea? Is LV interpreting this the same as cluster of 2 32bit ints?

0 Kudos
Message 3 of 4
(3,147 Views)
Solution
Accepted by Skoda3

@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:

cluster to 64 bit.png

 

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.

Rolf Kalbermatter
My Blog
Message 4 of 4
(3,140 Views)