has incomplete type

Discussion in 'C Programming' started by onsbomma, Mar 10, 2005.

  1. onsbomma

    onsbomma Guest

    Can anyone tell me the difference between


    typedef struct chunkinfo* mfastbinptr;

    and

    typedef struct chunkinfoptr chunkinfoptr;


    if you know that

    struct chunkinfo{
    struct chunkinfo* next;
    struct chunkinfo* prev;
    int size;
    };

    typedef struct chunkinfo* chunkinfoptr;

    With the second i get a "has incomplete type" error
     
    onsbomma, Mar 10, 2005
    #1
    1. Advertising

  2. onsbomma wrote:

    > Can anyone tell me the difference between
    >
    >
    > typedef struct chunkinfo* mfastbinptr;
    >
    > and
    >
    > typedef struct chunkinfoptr chunkinfoptr;
    >
    >
    > if you know that
    >
    > struct chunkinfo{
    > struct chunkinfo* next;
    > struct chunkinfo* prev;
    > int size;
    > };
    >
    > typedef struct chunkinfo* chunkinfoptr;

    Note that the '*' means a pointer.

    >
    > With the second i get a "has incomplete type" error


    Let us do some simple substitutions:
    The original problem line:
    typedef struct chunkinfoptr chunkinfoptr;

    Substitute "struct chunkinfo *" for chunkinfoptr:
    typedef struct struct chunkinfoptr * chunkinfoptr;

    Do you see the error?
    Also, please don't use a structure tag as a type-id.
    So, what are you trying to do?

    Your code fragment above indicates some confusion
    issues.

    --
    Thomas Matthews
     
    Thomas Matthews, Mar 10, 2005
    #2
    1. Advertising

  3. onsbomma

    Eric Sosman Guest

    onsbomma wrote:
    > Can anyone tell me the difference between
    > [...]


    Please post the actual code and the actual error message.
    Post a minimal but complete example that someone else could
    process with a compiler. Trying to reconstruct what you were
    actually doing is an error-prone process, likely to lead to
    a diagnosis of a problem entirely different from the one you
    are struggling with.

    --
     
    Eric Sosman, Mar 10, 2005
    #3
  4. onsbomma

    leon Guest

    There are 3 "chunkinfoptr" here in your code.

    onsbomma wrote:
    > Can anyone tell me the difference between
    >
    >
    > typedef struct chunkinfo* mfastbinptr;
    >
    > and
    >
    > typedef struct chunkinfoptr chunkinfoptr;


    The 1st "chunkinfoptr" is an undefined struct.
    The 2nd "chunkinfoptr" is an identifier of the undefined struct.
    >
    >
    > if you know that
    >
    > struct chunkinfo{
    > struct chunkinfo* next;
    > struct chunkinfo* prev;
    > int size;
    > };
    >
    > typedef struct chunkinfo* chunkinfoptr;

    The 3rd "chunkinfoptr" is a type identifier.

    >
    > With the second i get a "has incomplete type" error


    The thred "chunkinfoptr" are not conflict to each other in that they
    are in different namespaces (typedef, struct and identifier).

    But when you try to create a variable of the 2nd "chunkinfoptr", the
    compiler will compalain "incomplete type", because "struct
    chunkinfoptr" is undefined.
     
    leon, Mar 11, 2005
    #4
    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. Halid Umar A M

    Error: field has incomplete type

    Halid Umar A M, Apr 27, 2006, in forum: C Programming
    Replies:
    2
    Views:
    746
    David Resnick
    Apr 27, 2006
  2. gk245
    Replies:
    2
    Views:
    1,209
    Christopher Benson-Manica
    May 6, 2006
  3. Replies:
    1
    Views:
    558
    Jim Langston
    May 2, 2007
  4. Replies:
    1
    Views:
    964
    Richard Bos
    Jan 17, 2008
  5. arcadio

    Array has incomplete element type. GCC bug?

    arcadio, Jun 23, 2008, in forum: C Programming
    Replies:
    11
    Views:
    2,188
Loading...

Share This Page