typedefs and structs [was Re: [PATCH 16/42]: PCI: PCI Error reporting callbacks]
Steven Rostedt
rostedt at goodmis.org
Tue Nov 8 12:11:13 EST 2005
On Mon, 2005-11-07 at 14:41 -0600, linas wrote:
>
> > > Also, "grep typedef include/linux/*" shows that many kernel device
> > > drivers use this convention.
> >
> > They are wrong and should be fixed.
>
> What, precisely, is wrong?
I can't seem to find it on google, but IIRC Linus stated that he didn't
want any more structures defined with typedefs. If it is a structure,
simple keep it one, and don't use typedef to get rid of "struct".
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.
So in my every day programming, I switched to not typedef structures
anymore, and I even found some places that I passed structures by value
when it would have been much more efficient by reference.
The only exceptions that I can see where you typedef a structure is for
use with arch dependent types, like atomic_t.
-- Steve
More information about the Linuxppc64-dev
mailing list