我有一個結構定義爲: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