Re: struct syntax



> /* Style 1 */
> typedef struct _Thing Thing;
> struct _Thing {
> /* stuff */
> };


> /* Style 2 */
> typedef struct {
> /* stuff */
> } Thing;

> So why do I see Style 1 all over the place?  There must be something I'm
> missing.

I don't know the "real reason" for that, or even if there is hard reason.
But my
guess is that as you say, when using Style1 you can easily hide the
structure in
the .c file. We use it even when the struct is in the .h file but this makes
it easier
if we later want to move it to the .c  file. I don't see any advantages of
Style 2
v.s. style one, plus everybody is familiar with style 2.

Maybe there is anther reason that i am not aware of.

regards,
Chema





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]