Typedef Union

typedef union _WORD_VAL { WORD val; struct { BYTE LSB; BYTE MSB; } byte; BYTE v[2]; } WORD_VAL; # = ((DWORD_VAL) address).v[1])

Read More

Typedef For State Machines

typedef enum _SM_USER_MODE { SM_POWERUP, SM_ONLINE, SM_OFFLINE, SM_IDENTIFY } SM_USER_MODE; Example Usage typedef enum _SM_USER_MODE { SM_POWERUP, SM_IDLE } SM_USER_MODE; void my_function (void) { static int user_mode = SM_POWERUP; static int user_mode_last = ~SM_POWERUP; BYTE this_is_new_mode = 0; //—– CHECK FOR THIS IS NEW MODE —– if (user_mode_last != user_mode) { this_is_new_mode = 1; user_mode_last […]

Read More

Typedef, struct union

Typedef Union For Different Definitions Of The Same Memory Locations typedef union _SYSTEM_CONFIGURATION_TYPEDEF { DWORD dw[25]; WORD w[50]; BYTE b[100]; } SYSTEM_CONFIGURATION_TYPEDEF; SYSTEM_CONFIGURATION_TYPEDEF system_config_buffer; system_config_buffer.b[0] = 1; system_config_buffer.b[1] = 2; system_config_buffer.b[2] = 3; system_config_buffer.b[3] = 4; system_config_buffer.b[4] = 5; //Will give: //system_config_buffer.w = 0x0201 //system_config_buffer.dw = 0x04030201 Typedef Struct typedef struct _TEST_HEADER { WORD source_port; […]

Read More