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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]