home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12378 < prev    next >
Encoding:
Text File  |  1992-08-15  |  1.8 KB  |  47 lines

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