Got the following data struct:
typedef struct
{
lamp *lamp;
unsigned char a;
unsigned char b;
unsigned char c;
unsigned char d;
unsigned char e;
void (*func)(struct event *);
} event;
The last line inside the struct is supposed to be a pointer to a function with return type void with pointer to an event as an argument such as:
void function(event *evt);
Though, I get the following warning message: "its scope is only this definition or declaration, which is probably not what you want". Is this right or wrong?
Your struct needs needs to be defined like this:
typedef struct event // <<< note the `event` tag here
{
lamp *lamp;
unsigned char a;
unsigned char b;
unsigned char c;
unsigned char d;
unsigned char e;
void (*func)(struct event *);
} event; // <<< you can still keep `event` as a typedef
// which is equivalent to `struct event`
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.