home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!gdt!aber!aberfa!pcg
- From: pcg@aber.ac.uk (Piercarlo Grandi)
- Newsgroups: comp.lang.c++
- Subject: Re: linkage specification and const objects
- Message-ID: <PCG.92Aug15145921@aberdb.aber.ac.uk>
- Date: 15 Aug 92 14:59:21 GMT
- References: <1992Aug13.174157.6794@dg-rtp.dg.com>
- Sender: news@aber.ac.uk (USENET news service)
- Reply-To: pcg@aber.ac.uk (Piercarlo Grandi)
- Followup-To: comp.lang.c++
- Distribution: gnu
- Organization: Prifysgol Cymru, Aberystwyth
- Lines: 30
- In-Reply-To: hassey@matrix.rtp.dg.com's message of 13 Aug 92 17: 41:57 GMT
- Nntp-Posting-Host: aberdb
-
- On 13 Aug 92 17:41:57 GMT, hassey@matrix.rtp.dg.com (John Hassey) said:
- Followup-To: comp.lang.c++
-
- hassey> So g++ wants something like this to be happy:
- hassey> extern "C" extern const int a;
- hassey> But cfront doesn't like that at all.
- hassey> It looks to me like g++ is wrong on this one.
-
- No, it's actually correct. extern "C" does not change the linkage of an
- object. The 'extern' in it is just another example of the remarkable
- keyword overloading of C++.
-
- hassey> extern "C" const int a;
- hassey> is a declaration not a definition (7.4). But
-
- No, the opposite. It is the definition of a constant 'a' which is
- exported using "C" conventions. Just ignore the presence of extern "C".
- The language in the ARM on this may be imprecise, but the general
- principle stands.
-
- hassey> extern "C" { const int a; };
- hassey> Is a definition, so the error is justified on this, and cfront
- hassey> 2.1 does give an error.
-
- extern "C", with braces or not, does not confer extern linkage by
- itself. Indeed this is a little known thing.
- --
- Piercarlo Grandi | JNET: pcg@uk.ac.aber
- Dept of CS, University of Wales | UUCP: ...!mcsun!ukc!aber-cs!pcg
- Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@aber.ac.uk
-