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)?
staticvariables are placed in a different section. See also here: stackoverflow.com/questions/93039/…mainrecursively (later in the code)?staticmeans the variable is not allocated in the stack (stored in data segment or in BSS segment).int arr[100000000];, and see what happens.mainrecursively, but that is a different language.