简体   繁体   中英

warning: initialization from incompatible pointer type

I'm completely stuck at this point. I have the following code:

typedef void    (*TPFN_ACC)(void); 
typedef char    (*TPFN_EVE)(void); 


typedef struct {
  int           idDestino;            
  char        * nombre;         
  TPFN_EVE      evento;         
  TPFN_ACC      accion;        
} TRANSICION;

And then I do this:

TRANSICION transiciones_Stopped[] = {
    {UPLEFT, "t_Stopped_to_Up_Left", ev_up_left, acc_up_left},
    {0, 0, 0, 0}
};

And I'm getting this warning:

warning: initialization from incompatible pointer type

Could you please help me?

Thanks in advance.

You have this:

void ev_up_left();
char acc_up_left();

and in your TRANSICION structure, member evento of type char (*)(void) is initialized with ev_up_left of type void (*)(void) .

Same for member accion of type void (*)(void) initialized with acc_up_left of type char (*)(void) .

You probably swapped the two types / two structure members by mistake.

change

typedef void    (*TPFN_ACC)(void); 
typedef char    (*TPFN_EVE)(void);

to

typedef void    (*TPFN_EVE)(void); 
typedef char    (*TPFN_ACC)(void);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM