how to use a macro of structure ?
Here I am listing steps for it by using a demo:
- macro a structure:
#define structed_define { "this is a demo for structed",1883 }
this is a macro for structure.
- define a structure class:
typedef struct_static { char* name; int port; } xi_static_host_desc_t;
this is a structure class
- define a const class which is using the structure: #define XI_MQTT_HOST_ACCESSOR ( ( xi_static_host_desc_t )structed_define)
- assign buffer and int :
unsigned int b; char buf[32]; b=XI_MQTT_HOST_ACCESSOR.port; memcpy(buf,XI_MQTT_HOST_ACCESSOR.name,strlen(XI_MQTT_HOST_ACCESSOR.name));
End
- Note.