LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview equivalent of C pointer

Dear All,
 
In the Labview program, that I'm currently writting, I'm using a dll that was written in C. The C function I'm trying to call, is expecting a pointer to char in its prototype like so: void example(unsigned char *a); What is the Labview equivalent of a char *.
 
Thanks in advance for your help,
 
Regards,
 
Alan
0 Kudos
Message 1 of 5
(3,575 Views)
A char in C is equivalent to a U8 in Labview.  When setting up the DLL call, there is a Pass drop down box for parameters.  Choose the pass by pointer option.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 5
(3,572 Views)

Good morning,

Thank you for your message. I know how to set up a Labview dll function call that expects a pointer, but I don't know how I'm to wire up the Labview equivalent, if you see what I mean. If I give it the first element of the array only (address of array in C), Labview is happy, but I'm not convinced I'm doing the right thing.

Thanks in advance for any help,

Regards,

Alan

0 Kudos
Message 3 of 5
(3,543 Views)
Hi Alan,

There's a useful example that ships with LabVIEW that explains how you pass different data types to DLLs. If you open and run the Call DLL example (you can find it by searching for "DLL" in the NI Example Finder") you can browse to the datatype you require and then open an example that shows how to pass the data correctly.

If this doesn't address your query let me know and I'll have a look for some other information for you.
Sarah

Applications Engineer | National Instruments | UK & Ireland
0 Kudos
Message 4 of 5
(3,529 Views)

There is a difference in passing a char type and a char array (string).  First of all, C expects the string to end with the NULL character (\0).  You need to append the NULL to the string, then convert the string to a byte array (String to Byte Array function).  Then in order to pass the array to the C DLL, you need to declare the parameter as Type=Array, Data Type=U8, Dimensions=1, Array Format=Array Data Pointer.  This will pass the string into the DLL.

 

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 5
(3,507 Views)