08-15-2016 11:10 AM
I have a c++ module that returns a string value. TestStand doesn't appear to be able to see strings as a Return Value. Is it possible for c++ to return a string to teststand? I have other methods that return return bool and float values and TestStand handles those without a problem..
Solved! Go to Solution.
08-16-2016
03:59 PM
- last edited on
10-28-2024
04:56 PM
by
Content Cleaner
Hi,
Could you describe any errors that you may be seeing? I've found a few resources that cover certain aspects of this issue, though they may not be directly applicable pending your system. I'd be glad to assist you further with more detail.
String Value Test Step
https://www.ni.com/docs/en-US/bundle/teststand-api-reference/page/tsref/string-value-test-step.html
C/C++ DLL Call Parameters
Regards,
Finch Train
08-17-2016 09:26 AM
The problem is that there is no standard memory allocation for C/C++. The string could be allocated on the heap (or might not be, there is no way of knowing if it's just returned as char *) and thus if you return it to TestStand and don't otherwise manage the memory it will leak, or worse, could get deallocated out from underneath TestStand. That is why TestStand does not support this. If you use an output parameter instead, teststand can allocate its own memory for the string and you can copy the string into that.
Hope this helps,
-Doug
08-18-2016 12:55 AM
08-19-2016 08:17 AM
Thank you for the help! This led me to the solution that I needed. I did just as you said, I created an output parameter and returned the string through that parameter successfully.