From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

TestStand does not find all the function exported DLL

Solved!
Go to solution

Hi all,

 

My problem is the following :

 

I have a DLL that I compile with Visual Studio with 40 functions. When I want to use this DLL in teststand, there is two function missing. If I check with dependency walker, the 2 missing function in teststand are well exported.

 

Missing function prototype :

struct HModemBoardOpaqueType * mbCreateModemBoard(void)

 

Good function prototype :

enum UbtDllErrorCode mbDisconnectFromModemboard(struct HModemBoardOpaqueType *)

 

Is that possible that teststand does not handle struct with opaque type correctly ?

 

If I export my function C-style (with extern C) no function is missing in test stand

 

Thanks

0 Kudos
Message 1 of 3
(4,367 Views)
Solution
Accepted by topic author Apophis91

What version of TestStand are you using? Older versions of TestStand only supported void, numeric, and boolen data types for return values from the dll adapter. Newer versions of TestStand now support Pointer/Handle as well. For new versions of TestStand I would expect it to allow you to use such a prototype with the Pointer/Handle data type. However, if you want to convert that struct to an equivalent TestStand custom data type, you will need to make it a parameter instead of a return value, since the adapter does not support struct conversion for return values.

 

Fundamentally returning a struct pointer this way (as a return value) is unsafe in C/C++ because it is not possible to know who owns the memory. The Pointer/Handle type allows you to do this anyway, but you have to be careful to correctly maintain the lifetime of the memory you are returning at a lower level (i.e. perhaps with an exported function that takes the pointer that knows how to free it).

 

Hope this helps,

-Doug

0 Kudos
Message 2 of 3
(4,322 Views)

Thank you Doug,

 

I have been able to use the pointer/handle type with my DLL. I use a function release(handle) in order to take care of the memory.

0 Kudos
Message 3 of 3
(4,278 Views)