After I have defined an enum like this:
typedef enum { x = 1ULL<<40 } e;
it seems that the expression 'x' evaluates to 1UL<<40.
However, C11 6.4.4.3 says "An identifier declared as an enumeration constant has type int."
Incidentally this saves my day, since I want enum values > 1<<32. However, I need to know how this can be; I'm a bit nervous to write code that isn't standards compliant.
I tried this code:
int main() {
printf("%zu %zu %lx\n", sizeof(e), sizeof(x), x);
return 0;
}
Compiling with gcc -std=c11 -Wall (gcc 8.3.1, linux x86_64), it outputs: 8 8 10000000000.
If I change %lx to %llx, I get a compile warning and the same output, which indicates x is long-sized.
Based on my reading of the spec, I would expect compile warnings and output 4 4 0.