Error: field has incomplete type

Discussion in 'C Programming' started by Halid Umar A M, Apr 27, 2006.

  1. 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.
    Halid Umar A M, Apr 27, 2006
    #1
    1. Advertising

  2. Halid Umar A M

    Flash Gordon Guest

    Halid Umar A M wrote:
    > 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.

    <snip>

    > 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.
    --
    Flash Gordon, living in interesting times.
    Web site - http://home.flash-gordon.me.uk/
    comp.lang.c posting guidelines and intro:
    http://clc-wiki.net/wiki/Intro_to_clc
    Flash Gordon, Apr 27, 2006
    #2
    1. Advertising

  3. Halid Umar A M wrote:
    > 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
    David Resnick, Apr 27, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. onsbomma

    has incomplete type

    onsbomma, Mar 10, 2005, in forum: C Programming
    Replies:
    3
    Views:
    775
  2. Replies:
    1
    Views:
    554
    Jim Langston
    May 2, 2007
  3. Replies:
    1
    Views:
    956
    Richard Bos
    Jan 17, 2008
  4. arcadio

    Array has incomplete element type. GCC bug?

    arcadio, Jun 23, 2008, in forum: C Programming
    Replies:
    11
    Views:
    2,176
  5. jr
    Replies:
    3
    Views:
    415
Loading...

Share This Page