has incomplete type

O

onsbomma

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
 
T

Thomas Matthews

onsbomma said:
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.
 
E

Eric Sosman

onsbomma said:
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.
 
L

leon

There are 3 "chunkinfoptr" here in your code.
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.
 

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,817
Latest member
DicWeils

Latest Threads

Top