The size_t datatype does not have a direct equivalent in TestStand. Therefore, you cannot pass out a value from a function in a DLL and store it directly into a numeric variable in TestStand without setting the representation of the variable to Double Precision 64-bit Floating-Point
in 32-bit TestStand or Unsigned 64-bit Integer
in 64-bit TestStand.
Instead, you can define the function in your DLL to pass a pointer to your variable but still return the actual value of the variable. In TestStand, you can then set the Return Value
type from your function to Pointer/Handle
and store the variable in an Object Reference Variable
. The screenshot below highlights where to define these settings in the parameters of your DLL in TestStand.
You can then retrieve the value of that Object Reference variable by inputting the expression below into an expression step. Note: This code will work on both 32-bit and 64-bit TestStand if Locals.Int64Number
is a Signed 64-bit Integer
, however only the low order 32-bits of the integer will be used on 32-bit TestStand.Locals.Int64Number = (&Locals.objectRefVariable).AsPropertyObject.GetValInteger64("", PropOption_Coerce)
The value of your size_t data will then be stored in Locals.Int64Number and can be used as a regular 64-bit signed integer.
Similarly, if you want to modify the value of Locals.Int64Number then pass it back to the DLL, you can use the following statement to convert the signed 64-bit integer back into an objectRefVariable.(&Locals.objectRefVariable).AsPropertyObject.SetValInteger64("", PropOption_Coerce, Locals.Int64Number)Once you have the new value stored in Locals.objectRefVariable, you can pass it back into the DLL by calling a function that requires a size_t pointer as an input. In TestStand, you will then have to select the parameter you are passing into the DLL, click on the Category field drop-down menu and select Pointer/Handle as the value. You will also have to click the drop-down menu for the Pass field and select By Value as the value.
The screenshot below highlights where to define these settings in the parameters of your DLL in TestStand.