• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
static / extern fails in GCC 4
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: static / extern fails in GCC 4
      • From: Cameron Hayne <email@hidden>
  • Prev by Date: Re: Adding projects' libraries to a project
  • Next by Date: Re: static / extern fails in GCC 4
  • Previous by thread: Re: Adding projects' libraries to a project
  • Next by thread: Re: static / extern fails in GCC 4
  • Index(es):
    • Date
    • Thread