Why don't you print it?
/* C99 */
#include <stdio.h>
typedef enum { a = 0, b = 7, c = 10 } data_10_type;
printf("%zu\n", sizeof(data_10_type));
The identifiers in an enumerator list are declared as constants that have type int
(C11 §6.7.2.2 Enumeration specifiers), so sizeof(data_10_type)
is often equal to sizeof(int)
, but it isn't necessary!
BTW, if you want to have a size in bits, just use the CHAR_BIT
constant (defined in <limits.h>
), which indicates how many bits there are in a single byte).
/* C99 */
#include <limits.h>
#include <stdio.h>
typedef enum { a = 0, b = 7, c = 10 } data_10_type;
printf("%zu\n", sizeof(data_10_type) * CHAR_BIT);