--- In [email protected], Ray Devore <[EMAIL PROTECTED]> wrote: > > --- John Matthews <[EMAIL PROTECTED]> wrote: > > --- In [email protected], Ray Devore > > <rbdevore2007@> wrote: > > > > > > I keep seeing two different ways to define a > > struct > > > (see below). What is the benefit of doing the > > typedef > > > over just defining the struct with a tag? Is one > > more > > > efficient than the other? > > > > The run-time efficiency isn't going to change, and > > I'm not sure about > > C++. But in C the typedef without tag creates an > > unnamed structure, > > and I've used C compilers in the past which only say > > 'error in > > unnamed' if they detect a related error. > > > > You can always use a typedef and a tag eg. > > > > struct tag_T { ... }; > > typedef struct tag_T T; > > > > or > > > > typedef struct tag_T { ... } T; > > > > John > > > But why use one over the other?
You mean if you use a typedef *and* a tag (which wasn't the original question as I understood it, apologies if I got that wrong), what's the difference between doing it in 2 lines and doing it in 1? Well I guess doing it in one line is bad if you're paid by the number of lines of code you produce. But good if you're trying to improve your comments to code ratio :-) (In other words, none AFAIK.) John
