Specifying size of enum type in C

Will picture Will · Feb 2, 2011 · Viewed 78.4k times · Source

Already read through this related question, but was looking for something a little more specific.

  • Is there a way to tell your compiler specifically how wide you want your enum to be?
  • If so, how do you do it? I know how to specify it in C#; is it similarly done in C?
  • Would it even be worth doing? When the enum value is passed to a function, will it be passed as an int-sized value regardless?

Answer

Nyx0uf picture Nyx0uf · Feb 2, 2011

I believe there is a flag if you are using GCC.

-fshort-enums