Hi!
I'm rather new at c++ and I'm totally confused with this kind of
typecasting:
typedef signed char int8_t;
typedef signed short int16_t;
typedef struct broadcast_hdr
{
broadcast_type_t broadcast_type;
uint16_t items_n;
uint16_t size_n;
} broadcast_hdr_t;
typedef struct broadcast_type
{
char ac;
char bc;
uint16_t number_n;
} broadcast_type_t;
typedef struct ob_levels_price
{
uint16_t maskA_n;
uint16_t maskB_n;
uint8_t levels_c;
uint8_t items_c;
char filler_2_s [2];
} ob_levels_price_t;
void HandleBroadcast(int8_t* broadcast, uint16_t length)
{
static broadcast_type_t typeA = {'B','I',9};
static broadcast_type_t typeB = {'B','D',6};
static broadcast_type_t typeC = {'B','O',14};
broadcast_type_t* bc;
bc = (broadcast_type_t*)broadcast;
if (memcmp(bc, &typeC, sizeof(broadcast_type_t)) == 0)
{
SpecificBroadcast(broadcast, length);
return;
}
}
void SpecificBroadcast(int8_t* broadcast, uint16_t length)
{
ob_levels_price_t* obPriceVolumes = (ob_levels_price_t*)broadcast;
broadcast_hdr_t* bc = (broadcast_hdr_t*)broadcast;
uint32_t substart = sizeof(*bc);
uint8_t *pBc = (uint8_t*)bc;
}
Can someone explain to me SpecificBroadcast. I don't understand how
the contents of an signed char (int8_t) can be converted to a struct
(ob_levels_price_t, broadcast_hdr_t) through its address. What could
possibly be the contents of the broadcast variable???
Really stumped.
Thanks in advance.