0

raspberry pi我使用 Visual Studio 构建项目并在VisualGDB 的帮助下使用位于的 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声明。为什么以及如何解决它?

4

1 回答 1

2

编译器不理解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 编译

于 2021-10-28T14:04:55.437 回答