Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   has incomplete type (http://www.velocityreviews.com/forums/t437267-has-incomplete-type.html)

onsbomma 03-10-2005 07:02 PM

has incomplete type
 
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

Thomas Matthews 03-10-2005 08:22 PM

Re: has incomplete type
 
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

Eric Sosman 03-10-2005 08:26 PM

Re: has incomplete type
 


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@sun.com


leon 03-11-2005 10:27 PM

Re: has incomplete type
 
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.



All times are GMT. The time now is 11:01 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.