What is the size of an enum in C?

前端 未结 7 1838
无人及你
无人及你 2020-11-22 08:55

I\'m creating a set of enum values, but I need each enum value to be 64 bits wide. If I recall correctly, an enum is generally the same size as an int; but I thought I read

7条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 09:13

    In C language, an enum is guaranteed to be of size of an int. There is a compile time option (-fshort-enums) to make it as short (This is mainly useful in case the values are not more than 64K). There is no compile time option to increase its size to 64 bit.

提交回复
热议问题