lkml.org 
[lkml]   [2005]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: typedefs and structs
From
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.

--linas
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-11-09 00:39    [W:0.133 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site