What are the differences and advantages between "typedef struct" and "struct"?

Asked

Viewed 379 times

1

I saw that the structure statement is not a standard among many programmers, while some use the typedef struct, others use only struct.

  • Which is best to use?
  • Has some difference in performance?

1 answer

1


In C++ there is no important difference (there are some corner cases but don’t worry about it), all struct is typedefed automatically (at least if I’m not inside a function, I don’t remember if the same thing happens there, I see little sense). In C it’s different.

So there’s no performance gain or any other, he accepts the typedef in struct only for compatibility with C.

In some cases (no struct) where the typedef it is still necessary to recommend now the using to create a name alias.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.