Paul Mackerras wrote: >Mark A. Greer writes: > > > >>Ahh, G*d I hate that...struct aaa, struct bbb, struct ccc all over the >>place when its not necessary & adds no value. Anyway, I will do that. >> >> > >It does make things clearer for the reader - when you see a >declaration "struct foo bar;" you know that it is a struct, but if you >see "foo_t bar;" you have no clue what sort of thing it is without >going and looking elsewhere. > Yes but chances are you're going to look it up anyway (no matter what type of creature it is). Plus with cscope or something similar its pretty quick/easy to look it up.
>The other advantage to using "struct" is that it can help straighten >out include file messes. If you have a header where you need to >declare a function that takes a foo_t *, you have no choice but to >#include <foo.h>, or whatever the header is that defines foo_t. That >can easily lead to messes where foo.h needs to include other things >which end up including everything plus the kitchen sink. If you >instead declare your function as taking a struct foo *, then you can >solve the problem by simply putting a "struct foo;" declaration in >your header, and then you don't need to #include <foo.h>. > > Hmm, it seems like the real problem in this example is that the include files are not written and/or split out well. Isn't your "struct foo;" example just a hack to work around that? Or am I not getting it? Anyway, I'll use "struct foo;"s from now on (and get rid of the typedef's I already have). Mark ** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/