Re: struct syntax



On 01 Jul 2001 11:32:50 -0400, Nathan Cullen wrote:
> 
> In Gtk+/GNOME programming I often see: 
> 
> /* Style 1 */
> typedef struct _Thing Thing;
> struct _Thing {
> 	/* stuff */
> };
> 
> I also see:
> 
> /* Style 2 */
> typedef struct {
> 	/* stuff */
> } Thing;
> 
> 
> It seems as if Style 2 is alot clearer, and gets rid of an unnecessary
> middleman.
> 
> The only application of Style 1 that I can concieve of is so that you
> could hide implementation details from clients by placing the typedef in
> the header and defining the struct in the corresponding .c file.
> clients.  I saw this used effectively in bonobo-ui-node.
> 
> So why do I see Style 1 all over the place?  There must be something I'm
> missing.
Historical reasons; the original GTK+ had Style 1 all over the place and
it stuck.

Style 1 is of course ugly and evil, and all Right Minded people should
use Style 2 :)

 Federico




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