cguy
January 23rd, 2011, 02:42 AM
This is the code:
struct directory;
typedef struct directory directory_t;
typedef struct file
{
char name[256];
unsigned long size;
date_t created;
date_t modified;
directory_t parent; <---------- This line is troublesome
}file_t;
struct directory
{
char name;
struct directory *parent;
date_t created;
date_t modified;
};
and this is the compilation error:
error: field 'parent' has incomplete type
But I declared the second structure's prototype and then declared a type definition.
Why do I still get an error?
struct directory;
typedef struct directory directory_t;
typedef struct file
{
char name[256];
unsigned long size;
date_t created;
date_t modified;
directory_t parent; <---------- This line is troublesome
}file_t;
struct directory
{
char name;
struct directory *parent;
date_t created;
date_t modified;
};
and this is the compilation error:
error: field 'parent' has incomplete type
But I declared the second structure's prototype and then declared a type definition.
Why do I still get an error?