Ray Devore <[EMAIL PROTECTED]> wrote:
>
> I keep seeing two different ways to define a struct
> (see below).
What you have posted defines two different structs.
> What is the benefit of doing the typedef
> over just defining the struct with a tag?
Some C programmers don't typedef struct because
it clogs the name space.
> Is one more efficient than the other?
No.
> typedef struct
> {
> int ivar;
> double dvar
> } Tdstruct;
Note that this defines an anonymous struct and a synonym
for it.
> vs
>
> struct Tagstruct
> {
> int ivar;
> double dvar
> };
This defines a struct Tagstruct. Despite having the same
members (subject to semi-colon correction), the difference
in struct tags makes them different (and incompatible)
types.
--
Peter