我需要在源文件中定义一个结构,其他来源也应该能够看到它。我在一个源文件中声明结构,然后在标头中声明 extern 以包含在其他源中,但是编译器出现以下错误:
lcd.c(24): error: #147: declaration is incompatible with "struct graph_obj arrow_right" (declared at line 45 of "lcd.h")
.C 文件
struct graph_obj
{
const u16 *id;
int x,y;
u16 w, h;
};
u32 lcdid;
struct graph_obj btn0;
struct graph_obj btn1;
struct graph_obj btn2;
struct graph_obj btn3;
然后是 .h 文件
extern struct graph_obj
{
const u16 *id;
int x,y;
u16 w, h;
};
extern u32 lcdid;
extern struct graph_obj btn0;
extern struct graph_obj btn1;
extern struct graph_obj btn2;
extern struct graph_obj btn3;
所以我该怎么做?