Enumeration Parameters - C/C++ DLL Call Parameters

Enumeration Parameters

You can pass enumerations you create as named data types. When you create or edit an enumeration data type, you can specify whether the type can be a C structure argument and how the type represents itself in memory when you pass it to a structure parameter or array parameter.

The following settings are available in the Data Type ring control when you select Enumeration for the category type.

Numeric Data Type Setting Equivalent C Data Type
Signed 8-bit Integer char
Unsigned 8-bit Integer unsigned char
Signed 16-bit Integer short
Unsigned 16-bit Integer unsigned short
Signed 32-bit Integer long
Unsigned 32-bit Integer unsigned long
Signed 64-bit Integer long long, __int64
Unsigned 64-bit Integer unsigned long long, unsigned __int64
32-bit Real Number float
64-bit Real Number double

Enum Type

When you select the Enumeration category for a parameter, the C/C++ Adapter displays the Enum Type control. This control allows you to specify the Enumeration data type necessary for the parameter in the Value Expression control. Additionally, the Value Expression control becomes a combo box where you can select enumerators of the enumeration. You can also enter an enumeration name or the corresponding numeric value for the enumeration directly into the Value Expression or Function Call controls.

When you select an Enumeration parameter that accepts an enumerated type from a code module that has a type library, TestStand will automatically check if the Enumeration data type and the type library enumeration have exactly matching enumerators. If not, then the Enum Type chosen will be shown in red with a warning message regarding the detected mismatch.

Note In C++, you can specify the underlying type of an enumeration to be a signed or unsigned 64-bit integer by defining an enumerated type in either of the following ways: enum [tag] : __int64 {enum-list} [declarator]; or unsigned __int64 {enum-list} [declarator]; TestStand cannot identify the underlying type of an enumerated type and always interprets the underlying type of an enumerated type to be a 32-bit integer. If a C++ function uses an enumerated type parameter for which the underlying type is a 64-bit integer, you must change the parameter type in TestStand to Signed 64-bit Integer or Unsigned 64-bit Integer to prevent precision loss.

Pass by Value or by Reference

When you select the Enumeration category for a parameter, the C/C++ DLL Adapter displays the Pass control. which specifies whether TestStand passes the value of the argument you specify in the Value Expression control or passes a pointer to the argument. If you select By Pointer (*) or By Reference (&) , the adapter passes a pointer to the argument value.

If you choose to pass a pointer, the argument you specify in the Value Expression control must be the name of a variable or property. When you select the Enumeration category for the return value, you may leave the Value control empty or specify the name of a variable or property.

Note You can pass NULL to an Enumeration pointer parameter by passing an empty object reference or the constant Nothing . Do not pass the constant 0 .

Result Actions

The C/C++ DLL Adapter displays the Result Action ring control and the Set Error.Code to Value option for return values and parameters you pass by pointer. Depending on the settings of these controls, TestStand can automatically set the Error.Occurred and Error.Code properties of the step according to the value in the enumeration argument when the function returns.

Use the Result Action ring control to configure TestStand to set the Error.Occurred property to True when the return value or parameter value after the call is greater than zero, less than zero, equal to zero, or not equal to zero. Use the Set Error.Code to Value option to request TestStand to assign the output value of the argument to the Error.Code property.

Note When you set the parameter type to Signed 64-bit Integer or Unsigned 64-bit Integer, the Set Error.Code control is not visible to prevent setting a 64-bit integer value to the Error.Code property of the step. The Error.Code property is a double-precision, floating-point number and you cannot always store 64-bit integers precisely in a double-precision, floating-point number because of limitations of the double-precision, floating-point format.

See Also

Mapping Parameters