How can I print the result of sizeof() at compile time in C?
For now I am using a static assert (home brewed based on other web resources) to compare the sizeof() re
One more way (that actually works):
char __foo[sizeof(MyStruct) + 1] = {[sizeof(MyStruct)] = ""};
Works with old'ish gcc 5.x. Yields an error like this:
a.c:8:54: error: initializer element is not computable at load time
a.c:8:54: note: (near initialization for 'a[8]')
p.s. obviously, this one is (very) gcc specific. All other methods weren't working for me.