Joe said:
So many? I think "static" qualifier has precisely two meanings in C. One
as a storage class and one to suppress external linkage. What are some
of the others?
The problem is that these meanings (three, actually, if you count the
new feature in C99) are only this simple if you think in C, instead of
in terms of the problems you're trying to solve. "Storage class"?
"External linkage"? What planet are these C programmers from, anyway?
static int a;
int b;
void f(int c[static 10]) {
static int d;
int e;
...
}
"Now, you see, the first 'static' means that 'a' has internal linkage,
that is, you can't reference it from other units, unlike 'b'. Of course
'b' has static storage duration, just like 'a', so they're both
initialized to 0.
'c' is a static array argument, in this case, a static array with at
least 10 elements. You don't need to use this, but your program may get
faster if you do. If you use this you must always pass an array with at
least that many elements. 'c' does not have static storage duration, of
course.
'd' is local to 'f', just like 'e' (and 'c', of course), but unlike 'e',
the value of 'd' will be remembered across function calls. 'd' has
static storage duration, like 'b', so it will be automatically
initalized, but 'e' will not.
Got that? Good. And now, C++."
S.