C 数组类型的元素类型不完整
我正在尝试这样做:C 数组类型的元素类型不完整,c,C,我正在尝试这样做: typedef struct { float x; float y; } coords; struct coords texCoordinates[] = { {420, 120}, {420, 180}}; 但编译器不允许我:(此声明有什么问题?感谢您的帮助!请执行以下操作之一: typedef struct { float x; float y; } coords; coords texCoordinates[] = { {420, 1
typedef struct {
float x;
float y;
} coords;
struct coords texCoordinates[] = { {420, 120}, {420, 180}};
但编译器不允许我:(此声明有什么问题?感谢您的帮助!请执行以下操作之一:
typedef struct {
float x;
float y;
} coords;
coords texCoordinates[] = { {420, 120}, {420, 180}};
或
在C语言中,struct
名称位于与typedef
s不同的名称空间中
当然,您也可以使用typedef-struct-coords{float x;float y;}coords;
并使用struct-coords
或coords
。在这种情况下,您选择什么并不重要,但对于自引用结构,您需要一个结构名称:
struct list_node {
struct list_node* next; // reference this structure type - need struct name
void * val;
};
struct list_node {
struct list_node* next; // reference this structure type - need struct name
void * val;
};