Typedef struct and enum, why?

Possible duplicates:
Structure purpose, typedef struct, in C ++
typedef struct vs structure definition

In the code that I support, I often see the following:

typedef enum { blah, blah } Foo;
typedef struct { blah blah } Bar;

Instead:

enum Foo { blah, blah };
struct Bar { blah blah };

I always use the latter, and this is the first time I see the first. Therefore, the question arises as to why one style can be used over another. Any benefits? Also are they functionally identical? I believe that they are, but I'm not 100% sure.

+5
source share
2 answers

In C ++, this does not matter.

C, struct s, enum s union " ", , .

struct S { };

, -

struct S S;

, struct S - , S - .

S myStruct;

C, S struct ( ), typedef, struct .

+9

C.

  struct Bar { blah, blah };

C;

+3

All Articles