What is the size of an enum in C?

前端 未结 7 1714
无人及你
无人及你 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:16

    Just set the last value of the enum to a value large enough to make it the size you would like the enum to be, it should then be that size:

    enum value{a=0,b,c,d,e,f,g,h,i,j,l,m,n,last=0xFFFFFFFFFFFFFFFF};
    

提交回复
热议问题