home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!darwin.sura.net!haven.umd.edu!mimsy!lhc!lhc!warsaw
- From: warsaw@nlm.nih.gov (Barry A. Warsaw)
- Newsgroups: comp.lang.c++
- Subject: External or internal linkage according to ARM?
- Message-ID: <WARSAW.92Sep2153003@anthem.nlm.nih.gov>
- Date: 2 Sep 92 20:30:03 GMT
- Sender: usenet@nlm.nih.gov (usenet news poster)
- Reply-To: warsaw@nlm.nih.gov (Barry A. Warsaw)
- Organization: Century Computing, Inc.
- Lines: 49
-
-
- In the following example, should the symbol Singleton::OnlyOne have
- external linkage or internal linkage? Cfront 2.1 say external, but
- g++ 2.2.2 gives only internal and the question of which is correct has
- come up.
-
- ----single.h----
- #include <iostream.h>
- class Singleton
- {
- public:
- static const Singleton& const OnlyOne;
- void dosomething() { cout << "doing something" << endl; };
- protected:
- Singleton( void ) {};
- };
-
-
- ----single.cc----
- #include "single.h"
- class SingletonBuilder : public Singleton
- {
- public:
- SingletonBuilder( void ) {};
- };
-
-
- const SingletonBuilder secretlyBuiltByLibrary;
- const Singleton& const Singleton::OnlyOne = secretlyBuiltByLibrary;
-
-
- ----main.cc----
- #include "single.h"
- int main( int, char** )
- {
- Singleton::OnlyOne.dosomething();
- return( 0 );
- };
-
-
- Note that with g++ 2.2.2, if I change OnlyOne's definition to:
-
- static const Singleton& /* const */ OnlyOne;
-
- (ie no second const), then it compiles fine under g++. So who's
- wrong, cfront or g++?
-
- Thanks,
- -Barry
-