여기에 directory라는 구조체를 만들었습니다. 어떤 자식에 대한 이중 포인터와 부모에 대한 단일 포인터가 있습니다.C 언어에서 컴파일 타임 경고 더블 포인터
여기에 디렉토리를 추가하는 기능을 만들었습니다.
directory* add_dir (char* name , char* path , directory* parent) {
directory* d = malloc (sizeof (directory)) ;
memset (d , 0 , sizeof(directory)) ;
//WARNING by line below
d->children = (directory**)malloc (sizeof(directory*) * DIR_COUNT) ;
memset (d->children , 0 , sizeof(directory*) * DIR_COUNT) ;
//WARNING by line below
d->parent = (directory*) parent ;
//Wanrning by line below
parent->children[parent->alloc_num_child] = (directory*) d ;
}
나는 아이들과 부모 디렉토리에 하나의 포인터 이중 포인터를 가지고있는 구조체라는 디렉토리를 정의했습니다. 이것을 컴파일하면 경고가 표시됩니다.
Warnings :
warning: assignment from incompatible pointer type [enabled by default]
warning: assignment from incompatible pointer type [enabled by default]
warning: assignment from incompatible pointer type [enabled by default]
왜 내가이 경고를 받고 있는지 잘 모르겠습니까?
'형식 정의 구조체를 작성합니다? 'alloc_num_child''struct directorey'의 멤버도 없습니다. – BLUEPIXY