• 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
[SOLVED] Re: error: invalid use of 'static' in linkage specification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SOLVED] Re: error: invalid use of 'static' in linkage specification


  • Subject: [SOLVED] Re: error: invalid use of 'static' in linkage specification
  • From: Dieter Oberkofler <email@hidden>
  • Date: Sat, 19 Sep 2009 07:31:30 +0200

The use of an "unnamed namespace" is definitively an interesting new alternative but after some research I've found out that gcc bug 26068 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26068) fixed a syntactical problem I've fall into.

It is still absolutely valid to have a static function with C linkage but the gcc 4.2.1 compiler now checks for invalid uses of storage classes with unbraced linkage specifications.

In gcc 4.2.1 it's no longer valid o use: extern "C" static myFunc(void); // ERROR
but you must use the correct syntax: extern "C" {static myFunc(void);} // VALID

Thank you,
Dieter

On 17.09.2009, at 16:35, David Rowland wrote:


On Sep 17, 2009, at 12:09 AM, Dieter Oberkofler wrote:

Sure, but extern "C" is a linkage specification needed to link with C code from a C++ application and this "should" be valid!


"static" has two distinct meanings in C++. When it is applied to a member of a class it means that the member (data or function) belongs to the class and not to any individual object. When it is applied to a non-member it means that the name is visible only within the compilation unit.

The latter meaning comes from C, and it is opposite to "extern", hence incompatible. The C++ meaning has nothing to do with linkage or visibility. The two uses cannot be confused by the compiler, but they certainly can be by the programmer.

In "The Design and Evolution of C++", Bjarne Stroustrup says that the old meaning of "static" is deprecated and can be accomplished by using unnamed namespaces, leaving "static" with its new, C++ meaning. Of course that hasn't happened, and we are left with two meanings, plus the weird phrase "unnamed namespace".

David


 _______________________________________________
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

References: 
 >Re: error: invalid use of 'static' in linkage specification (From: Greg Guerin <email@hidden>)
 >Re: error: invalid use of 'static' in linkage specification (From: Dieter Oberkofler <email@hidden>)
 >Re: error: invalid use of 'static' in linkage specification (From: David Rowland <email@hidden>)

  • Prev by Date: Re: Using libcrypto & the 10.6 SDK with a minimum OS requirement of 10.5
  • Next by Date: const (char*) handling in gcc 4.2.1 versus gcc 4.0
  • Previous by thread: Re: error: invalid use of 'static' in linkage specification
  • Next by thread: where is the "Xcode Project Management Guide"?
  • Index(es):
    • Date
    • Thread