在 C 中声明结构

Declare structure in C

我使用 Visual Studio 构建项目并在 VisualGDB

的帮助下使用位于 raspberry pi 的 GCC 进行编译

我有结构简单的 c 文件:

struct labing
{
    lv_obj_t* panel;
    lv_obj_t* label; 
    const char* title;
    int high;
    int width;
};

void createTopPanel(lv_obj_t * screen, labing * lb)
{
...
}

编译器产生错误:

error: unknown type name ‘labing’; did you mean ‘long’?

看起来编译器不理解结构 labing 声明。为什么以及如何修复它?

编译器不理解labing,因为没有labing类型,只有struct labing类型。

要么像这样使用 typedef(这将执行 typedef struct 的声明):

typedef struct labing
{
    lv_obj_t* panel;
    lv_obj_t* label; 
    const char* title;
    int high;
    int width;
} labing;

或更改

void createTopPanel(lv_obj_t * screen, labing * lb)

void createTopPanel(lv_obj_t * screen, struct labing * lb)

所做的可以用 C++ 编译,但不能用 C 编译。