2016-11-24 12 views
0

これは不完全な型への逆参照ポインター|

#include<stdio.h> 
    #include<stddef.h> 

char memory[25000]; //Declare an array of 25000 bytes in size 

//Define data structure to save the details of the each memory block 
struct metaData{ 
int status; //save the status of the block is free or whether it is already  allocated 
size_t bSize; //save the block size in bytes 
struct metaData *next; //save the pointer to next header 
}; 

struct header *firstBlock=(void*)memory; //Initialise a pointer to the starting address of the memory 


void initializeMemory(){ 
firstBlock->bSize=25000-sizeof(struct metaData); 
firstBlock->status=1; 
firstBlock->next=NULL; 
} 

私のヘッダファイルであり、私はこのInitializeMemoryを(使用しようとすると)それが不完全な型へのポインタを参照解除言うとInitializeMemory()目的球を指摘しました。これのエラーは何ですか?

答えて

1

firstBlockstruct header *と宣言しました。 struct headerという構造体を実際に定義していないため、「不完全型」エラーが発生しています。代わりにstruct metaDataを定義しました。

代わりにstruct metaData *firstBlockを使用するとうまくいくはずです。

関連する問題