[lkml]   [2005]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: typedefs and structs
On Tue, Nov 08, 2005 at 12:18:42PM +1100, Neil Brown was heard to remark:
> 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;
> and the compiler will happily wait for the complete definition later
> (providing it doesn't need the size in the meanwhile).

Yes, this is the "forward declaration" problem I was refering to.
Its unavoidable if structs have circular references to each other.

However, I've learned, by experience, several things by trying to
eliminate such forward declarations (and the related #include hell):

-- Its really, really hard, and right in the middle, you think,
"gosh this is a stupid idea, why am I bothering?"

-- When you get done, you think: "wow this new code structure
is so insanely better than the old code! The guy who wrote
the old code should be hung from a yardarm as an example!"

So having a mechanism that prevents coders from declaring
"struct foo" whenever they feel like it can be a good thing.
Of course, your milage may vary.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-11-09 00:39    [from the cache]
©2003-2011 Jasper Spaans