When using DLLs written in C in LabVIEW, the datatypes from the DLL may be more complex than simple integers. In these cases, some considerations may need to be made to use the different datatypes.
For most DLLs, using the Import Shared Library Wizard will generate code that will handle simple datatypes like integers, floats, one-dimensional arrays and strings. However, there may be issues with the generation of the LabVIEW library that are shown on the last screen of the library generation.
One of the most common errors is produced when trying to use datatypes and functions that are not supported by the Import Shared Library Wizard, such as multidimensional arrays or functions returning a value that is not a numeric or string. These issues will show up in the Import Shared Library Wizard on the Configure VIs and Controls page with a red exclamation point glyph ( ) on the parameter. In those cases, you will have to use and configure a Call Library Function Node manually.
When using structs in your DLL, in order to ensure that the data being passed between LabVIEW and the DLL is aligned correctly in memory, it may be necessary to create a wrapper DLL around the DLL you want to call.
If you have a multidimensional array of data in LabVIEW and need a one-dimensional array, you can use the Reshape Array function to change the dimension of your array. Depending on the format that the DLL expects the data to be in, whether row- or column-major, you may have to transpose the array before reshaping it. This will swap the rows for columns and change the order in which the values appear in the one-dimensional array.
For more in-depth help on passing complex datatypes to and from DLLs, see External Code (DLL) Execution.vi in the LabVIEW Example Finder. It has examples on how to configure your Call Library Function Node to pass multiple complex datatypes. For example, there are examples on how to handle up to three-dimensional arrays and complex clusters. Some of these cases involve wrapping the generated DLL with custom C code as shown above.
Example C code for the DLL and requisite wrapper code are included in the <labview>\examples\Connectivity\Libraries and Executables\Source C Files directory.