static / extern fails in GCC 4
static / extern fails in GCC 4
- Subject: static / extern fails in GCC 4
- From: Dirk Stegemann <email@hidden>
- Date: Thu, 1 Dec 2005 15:00:42 +0200
Hello,
following peace of code
-----snip-----
extern const int kBuffer[3];
static const int kBuffer[3] = {1, 2, 3};
int main (int argc, char * const argv[]) {
// insert code here...
return 0;
}
-----snip-----
leads to a warning when compiled using GCC 3.3:
main.cpp:16: warning: `kBuffer' was declared `extern' and later `static'
With GCC 4, this is an error.
Does anybody know what's wrong with this code?
One explanation found with Google says:
"(...) that the "extern" in an anonymous namespace has about the same
meaning as static".
But I'm not sure how to interpret this.
Maybe, in general, a constant (or variable) can't be defined within
the same source code file where it is referenced via the "extern"
keyword?
Can anybody point to another solution than removing the "static"
keyword?
It should stay there for performance reasons, because 'kBuffer' is
usually much larger than 3 ints and contains a frequently accessed
table...
Thanks for hints,
Dirk Stegemann
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden