typedefs and structs [was Re: [PATCH 16/42]: PCI: PCI Error reporting callbacks]
Denis Vlasenko
vda at ilport.com.ua
Sat Dec 17 00:09:01 EST 2005
On Tuesday 08 November 2005 03:18, Neil Brown wrote:
> On Monday November 7, rostedt at goodmis.org wrote:
> >
> > This was for the simple reason, too many developers were passing
> > structures by value instead of by reference, just because they were
> > using a type that they didn't realize was a structure. And to make
> > things worse, these structures started to get bigger.
> >
>
> Another reason for not using typedefs is that if you do, and you want
> to refer to the structure in some other include file, you have to
> #include the include file that devices the structure.
> If you don't use typedefs, you can just say:
>
> struct foo;
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.
> and the compiler will happily wait for the complete definition later
> (providing it doesn't need the size in the meanwhile).
> So avoiding typedef means that you can sometimes avoid excess
> #includes, which means faster compiling.
--
vda
More information about the Linuxppc64-dev
mailing list