typedefs and structs [was Re: [PATCH 16/42]: PCI: PCI Error reporting callbacks]

Matthew Wilcox matthew at wil.cx
Sat Dec 17 00:22:24 EST 2005


On Fri, Dec 16, 2005 at 03:09:01PM +0200, Denis Vlasenko wrote:
> 
> Forward decl for typedef works too:
> 
> typedef struct foo foo_t;
> 
> is ok even before struct foo is defined. Not sure that standards
> allow thing, but gcc does.

Forward declarations of typedefs don't work in at least one case that
do for struct definitions:

$ cat foo.c
typedef struct foo foo_t;
typedef struct foo foo_t;
$ gcc -Wall -o foo.o -c foo.c
foo.c:2: error: redefinition of typedef 'foo_t'
foo.c:1: error: previous declaration of 'foo_t' was here

and if you don't believe we do that, take another look at our headers
sometime.



More information about the Linuxppc64-dev mailing list