Re: static / extern fails in GCC 4
Re: static / extern fails in GCC 4
- Subject: Re: static / extern fails in GCC 4
- From: Cameron Hayne <email@hidden>
- Date: Thu, 1 Dec 2005 08:23:45 -0500
On 1-Dec-05, at 8:00 AM, Dirk Stegemann wrote:
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;
}
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...
How about just removing the 'extern' declaration?
I'm not sure why you put it there in the first place. An 'extern'
declaration of a variable is used when you want to refer to a global
variable that "lives" in some other source file.
But with the 'static' in front of the line that defines that
variable, it is not a global variable - it is a file scope variable
(it cannot be accessed outside of the file where it is defined).
Having the 'static' there should not affect performance at all. I
think you are getting confused with an unrelated use of 'static' with
variables declared inside a block (e.g. inside a function).
--
Cameron Hayne
email@hidden
_______________________________________________
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