5
我试图做到这一点:数组类型具有不完整的元素类型
typedef struct {
float x;
float y;
} coords;
struct coords texCoordinates[] = { {420, 120}, {420, 180}};
但是编译器不会让我。 :?!(有什么不对的声明感谢您的帮助
我试图做到这一点:数组类型具有不完整的元素类型
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}};
OR
struct coords {
float x;
float y;
};
struct coords texCoordinates[] = { {420, 120}, {420, 180}};
在C,struct
名居住在比typedef
个不同的命名空间。
当然你也可以使用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;
};