Using Edge Extensions with the ThingWorx Edge C SDK > Macros for the Edge Extensions > Macros to Create twPrimitives from C Primitives
Macros to Create twPrimitives from C Primitives
C has its primitive types such as int, bool, char*, and double. The ThingWorx C API has its own core data type as well, the twPrimitive. The twPrimitive is Variant Type (refer to, which must be wrapped around a C primitive type before it can be used in a ThingWorx API call. This wrapping process involves the creation of a twPrimitive in the heap, which is then turned over to the API for management. The management includes releasing the twPrimitive back into free memory to prevent leakage. The ability to rapidly create twPrimitives from C primitives is important. The following is a list of macros to accomplish this for the most commonly used types:
TW_MAKE_EMPTY—Produces a primitive of type TW_NOTHING
You can also use simple API calls to create other primitives that are less commonly used. All primitive-creation macros call the C API functions of the form twPrimitive_CreateFrom...() such as twPrimitive_CreateFromNumber(), twPrimitive_CreateFromInteger(), and twPrimitive_CreateFromString(). Their main benefit is that they are shorter to type.
Was this helpful?