Re: previous declaration of Table was here / conflicting types for
by Flash Gordon <spam@[EMAIL PROTECTED]
>
May 3, 2008 at 10:32 AM
Michael.Z wrote, On 03/05/08 08:22:
> Anyone who can help:
>
> Given a Table.h file I am writing a Table.c file.
> I keep getting the compile error:
>
> previous declaration of Table was here / conflicting types for
>
>
> I think the problem was the result of two pieces of code.
> First: typedef struct Table; /* in Table.c*/
This says that Table is a struct.
> Second: struct Table { /*struct definition */ } *Table; /* in
> Table.h */
This says it is a pointer to a struct, that is what the * means.
> How can I solve the problems?
By not providing different definitions.
> Here are the two files
<snip>
> typedef void * Table ;
This is not what you said you had and is defining table as yet another
type.
<snip>
> typedef struct Table{
> int sizeTable;
> unsigned sizeData;
> int (*diff)();
> unsigned (*hash)();
> void *(*copy)();
> void (*free)();
> } * Table;
This is what you said. However pointers to void and pointers to structs
are different things for the simple reason that void and struct are
different.
Also hiding pointers behind a typedef is generally considered a bad thing.
--
Flash Gordon