Here, I have created a structure called directory. Which has double pointer to children and single pointer to parent.
typedef struct {
struct directory** children;
struct directory* parent ;
}directory;
Here, I have created a function to add 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 ;
}
I have defined a struct called directory which has double pointer to children and single pointer to parent directory. When I compile this I am getting warnings.
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]
I am not sure why am I getting this warnings ?