在这里,我创建了一个名为目录的结构。它具有指向子级的双指针和指向父级的单指针。
typedef struct {
struct directory** children;
struct directory* parent ;
}directory;
在这里,我创建了一个添加目录的函数。
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 ;
}
我已经定义了一个名为 directory 的结构,它具有指向子目录的双指针和指向父目录的单指针。当我编译这个时,我收到警告。
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]
我不确定为什么会收到此警告?