Reading over someone else's code, I saw something syntactically similar to this:
int main(void) {
static int attr[] = {FOO, BAR, BAZ, 0};
/* ... */
}
Is this an error or is there some reason to declare a variable in main
static
? As I understand it static
prevents linkage and maintains value between invocations. Because here it's inside a function it only does the latter, but main
is only invoked once so I don't see the point. Does this modify some compilation behavior (e.g. preventing it from being optimized out of existence)?