"Shyan Lam" <[EMAIL PROTECTED]> wrote:
> 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?
>
> In C language prior to C99, the struct tag alone cannot
> be used to declare an object of struct type:
>
> struct MY_STRUCT
> {
> ...
> };
>
> MY_STRUCT myObj; /* Error in C90 */
It is still an error in C99.
> In C++, the tag name can be used as a type without the
> 'struct' keyword:
True.
<snip>
> C99 follow suit and adapted this syntax.
Technically, it's valid syntax in that it follows the grammar,
however it is (still) not semantically valid. Struct tags
remain in a separate name space in C.
--
Peter