我有一个结构定义为:C编程:取消引用指针不完全型误差
struct {
char name[32];
int size;
int start;
int popularity;
} stasher_file;
和指针数组的那些结构:
struct stasher_file *files[TOTAL_STORAGE_SIZE];
在我的代码,我正在指向结构并设置其成员的指针,并将其添加到数组中:
...
struct stasher_file *newFile;
strncpy(newFile->name, name, 32);
newFile->size = size;
newFile->start = first_free;
newFile->popularity = 0;
files[num_files] = newFile;
...
我收到以下错误:
error: dereferencing pointer to incomplete type
无论何时我尝试访问newFile
中的成员。我究竟做错了什么?
谢谢大家的帮助:) – confusedKid 2010-04-05 01:59:50
顺便说一句,我有同样的错误,但问题是我没有包括一个特定的头文件(在一个大项目中)。 – ady 2016-05-06 18:51:39