2016-11-24 2 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() FUNTION. Какова ошибка этого?

ответ

1

Вы указали firstBlock как struct header *. Вы получаете ошибку «неполного типа», потому что вы на самом деле не определили структуру с именем struct header - вместо этого вы определили struct metaData.

Используйте struct metaData *firstBlock, и оно должно работать.

Смежные вопросы