Topic: Legality of names containing __


Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: Sun, 22 Jan 1995 11:24:22 GMT
Raw View
diamond@jrd.dec.com (Norman Diamond) writes:

>Scott.Maxwell@launchpad.unc.edu (Scott Maxwell) writes:
>>Are identifiers containing __ (e.g., foo__bar) reserved for special use by
>>the C standard or by the (emerging) C++ standard?  If not, does anyone
>>know whether such identifiers are "claimed" in any way by POSIX?
>
>The C standard reserves several classes of names according to *initial*
>substrings such as __ or str, but not according to appearance of such a
>substring elsewhere in the identifier.  I can't make such a bald assertion
>about the other standards, but intuitively believe they wouldn't dare.

Your intuitive belief is mistaken ;-)

The C++ standard _will_ reserve all identifiers containing two consective
underscores for use as identifiers with external linkage.
The reason is that C++ implementations typically use double underscores
for name mangling - for example, a name like foo__Fii might mean
`foo(int, int)'.  If you were to use names containing double underscores,
they might clash with the mangled names generated by the compiler.

--
Fergus Henderson - fjh@munta.cs.mu.oz.au
all [L] (programming_language(L), L \= "Mercury") => better("Mercury", L) ;-)




Author: Scott.Maxwell@launchpad.unc.edu (Scott Maxwell)
Date: 17 Jan 1995 22:34:26 GMT
Raw View
Are identifiers containing __ (e.g., foo__bar) reserved for special use by
the C standard or by the (emerging) C++ standard?  If not, does anyone
know whether such identifiers are "claimed" in any way by POSIX?

Thanks in advance for any help you can offer.

--
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Launchpad is an experimental internet BBS. The views of its users do not
necessarily represent those of UNC-Chapel Hill, OIT, or the SysOps.
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --




Author: jason@cygnus.com (Jason Merrill)
Date: Wed, 18 Jan 1995 08:30:00 GMT
Raw View
>>>>> Scott Maxwell <Scott.Maxwell@launchpad.unc.edu> writes:

> Are identifiers containing __ (e.g., foo__bar) reserved for special use by
> the C standard or by the (emerging) C++ standard?

Yes:

  2.8  Keywords                                                [lex.key]

3 In addition, identifiers containing a double underscore (__) or begin-
  ning with an underscore and an upper-case letter are reserved for  use
  by C++ implementations and standard libraries and should be avoided by
  users; no diagnostic is required.

Jason