Error: field has incomplete type

H

Halid Umar A M

Dear All,
Please tell me why this error is occuring. The following is the
code snippets which i have typed.

struct mystructure{
struct list_head m; //error: field m has
incomplete type
uint32_t ip;
time_t time;
};

struct another{
struct list_head m; //error: field m has
incomplete type
unsigned long count;
rwlock_t kern_lock; //error: syntax error before
rwlock_t
};

I have included linux/list.h for the list_head and inttype.h for the
uint32_t and finally i got the error

error: field m has incomplete type

error: syntax error before rwlock_t

Please tell me, why this error is happening.
 
F

Flash Gordon

Halid said:
Dear All,
Please tell me why this error is occuring. The following is the
code snippets which i have typed.

struct mystructure{
struct list_head m; //error: field m has
incomplete type

Please don't use // style comments when posting to news groups. As you
can see they don't survive line wrapping.

I have included linux/list.h for the list_head and inttype.h for the
uint32_t and finally i got the error

error: field m has incomplete type

error: syntax error before rwlock_t

Please tell me, why this error is happening.

For whatever reason you have not got a definition of list_head in scope
despite what you claim.

I'm guessing that linux/list.h is a linux specific header rather than
one of yours so if you post in a Linux group they might know how to use
it. When posting to a Linux group, make sure you provide a *complete*
source file showing the problem, not just a snippet. After all, if you
don't know what the problem is what makes you think you know which parts
of the file are relevant?

Here we only deal whith what the C standard covers. We don't deal with
Linux specifics, Windows specifics, or specifics of any other
implementation.
 
D

David Resnick

Halid said:
Dear All,
Please tell me why this error is occuring. The following is the
code snippets which i have typed.

struct mystructure{
struct list_head m; //error: field m has
incomplete type
uint32_t ip;
time_t time;
};

struct another{
struct list_head m; //error: field m has
incomplete type
unsigned long count;
rwlock_t kern_lock; //error: syntax error before
rwlock_t
};

I have included linux/list.h for the list_head and inttype.h for the
uint32_t and finally i got the error

error: field m has incomplete type

error: syntax error before rwlock_t

Please tell me, why this error is happening.

On my system, the linux/list.h includes this (stuff
not relevant to the issue snipped).

#if defined(__KERNEL__) || defined(_LVM_H_INCLUDE)
struct list_head {
struct list_head *next, *prev;
};
#endif

Unless you define one of the two symbols that are in the
implementations reserved name space, you won't have a declaration of
the struct list_head, and hence you will have an incomplete type.

If you want to discuss how or when to use this header, you should go to
a linux group for assistance.

-David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top