I was just fooling around in Xcode and I discovered that the following statement compiles and it doesn’t even raise a warning let alone an error:
static static static int static long static var[5];
What’s up with that? Does this make it super-DUPER static? 🙂
All joking aside, why does the compiler permit repeating the static modifier? Is there actually a reason to allow people to do this or were the people who wrote the compiler too lazy to make this raise an error?
I’m not an Objective-C developer, but does the language allow for an arbitrary ordering of modifiers (e.g. static volatile extern)? If so, then it’s probably a benign bug in the compiler that after reading a modifier (“
static” in this case) returns to a state where it accepts any modifier terminal again, and will do until it encounters the variable’s type. Continualstaticdeclarations wouldn’t contradict any prior modifiers so it wouldn’t raise any errors; so based on this I would expectvolatile volatile volatile int x;to also work.