Why is “typedef struct foo foo;” considered harmful?

The only downside(*) is that it hides the fact that foo is a struct, and not an alias for some builtin type.

Note(*): it’s matter of taste whether this is a downside for you.

  • It’s good for total opaqueness (see the first comment below).
  • To see why some people think this is a downside, check the linux kernel coding style (typedefs chapter).

Leave a Comment