jeudi 4 novembre 2021

Do not access a variable through a pointer of an incompatible type?

I write some code like this:

typedef struct {
    uint8_t ms;
    uint8_t op;
    uint16_t len;
} DATA_HEAD;
static int data_rcv(uint8_t *rdt)
{
uint16_t op;
int op_king;
DATA_HEAD *pH;

pH = (DATA_HEAD *)rdt;
op_king= data_check(pH->op);
}
static int data_check(uint8_t op) {
//some code
}

I build and get this warning:

Accessing an object through a pointer pH whose type DATA_HEAD* is incompatible with the type of the object. Do not access a variable through a pointer of an incompatible type.

How to fix this warning? Thanks very much!

Aucun commentaire:

Enregistrer un commentaire