LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Reference to Struct to DLL (Call Library Function)

Solved!
Go to solution

I have two functions written in C that takes reference to a struct.

 

Declarations:

IpAddress_Parse(IpAddress* address, const kChar* text)

 

ConnectIpAddress(connection, const kIpAddress* address)

 

typedef struct IpAddress
{
int version; 
unsigned char address[16];
} IpAddress;

 

 

Snippet:

void main(int argc, char **argv)

{

IpAddress ipAddress;

 

IpAddress_Parse(&ipAddress, "12.0.1.10");

ConnectIpAddress(connection, &ipAddress);

}

 

I am trying to convert the above to LabVIEW, but have trouble. I have tried to create a Cluster in LV and parse out data from IpAddress_Parse() and pass it back to ConnectIpAddress() as "Adapt to Type" to no avail. Even if I artificially construct a Cluster to pass to ConnectIpAddress() I would have error 1097 from LabView. My cluster included an int and a byte array which follows the typedef struct of IpAddress.

 

Please provide some pointers as what I am doing wrong. Thanks in advance.

0 Kudos
Message 1 of 3
(2,709 Views)
Solution
Accepted by Johnny3D

Please show your LabVIEW code. The IpAddress cluster should contain a 32-bit integer value, and a nested cluster containing 16 U8 values. You cannot replace a fixed-length C array with a LabVIEW array; you must use a cluster containing the same number of elements instead.

Message 2 of 3
(2,700 Views)

Hi nathand,

 

That was the culprit! Problem solved when I used cluster of elements to present array from C.

 

Thanks for your help!

0 Kudos
Message 3 of 3
(2,663 Views)