LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to declare a variable of scruct type which is defined with in DLL header?

Hello  every one,

  (As I mentione before, I am very beginner to  labview environment  🙂 )

 A function I am trying to call from imported DLL,  passes an adress of  struct type variable. The strcut variable is defined with in  header file of the DLL file. Do I need to declare the  struct variable  to pass its address  while calling the fuction from labview ?  if yes, would you explain how to  declare and initialize a varibale using the same struct name(the same struct name with in  the headere file) ?  e.g CIFX_PACKET tSendPkt = { 0 }; ,
CIFX_PACKET tRecvPkt = { 0 };......  'CIFX_PACKET' is struct   data type defined with in DLL header file.

 

 

Thank you very much for your help in advance

0 Kudos
Message 1 of 2
(2,882 Views)

You have two options:

1) Create a cluster in LabVIEW that matches the memory layout of the C struct. Wire the cluster constant to the Call Library Function Node, with the type set to "Adapt to Type." LabVIEW will automatically pass a cluster as a pointer to the cluster.

2) Create an array of bytes (using Initialize Array) of the same size as the struct, and configure the Call Library Function Node to pass the array by pointer. Write LabVIEW code to reintrepret that array as the desired data.

 

If your struct contains pointers, it gets more complicated. Post your struct definition if you want more specific help. The LabVIEW Help topic on "How LabVIEW Stores Data in Memory" is useful for getting the cluster/struct details right. You also need to be aware of how elements of the struct are aligned; you may need to add extra elements in the LabVIEW cluster for padding.

Message 2 of 2
(2,842 Views)