[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Processed: 008_fix_xgetpw_macro.diff breaks Xlib API.



On Wed, Apr 21, 2004 at 11:05:24AM +1000, Daniel Stone wrote:

> A leading underscore is universally accepted to denote
> 'internal' [...]

I don't know about "universally".  Anyone (like Gerd or I) who is
familiar with the ISO C standard knows that anything with a leading
underscore is reserved for the compiler or the standard C libraries.

>From section 7.1.3 Reserved identifiers:

  "All identifiers that begin with an underscore and either an uppercase
   letter or another underscore are always reserved for any use."

This means that this name space can be used by the implementation (of
the language standard, i.e. the compiler and/or libc) for preprocessor
macros or regular identifiers.

  "All identifiers that begin with an underscore are always reserved
   for use as identifiers with file scope in both the ordinary and tag
   name spaces."

This basically means that this name space can be used by the
implementation for regular identifiers, but not for macros.  You can
safely use identifiers with leading underscores (that don't match the
first rule) as structure/union members, but not much else.

  "If the program declares or defines an identifier in a context in which
   it is reserved [...] the behavior is undefined."

I won't bother to quote what the standard says about undefined
behavior.  Lets just take it as given that it's undesirable.  So
anyone who "universally accept[s]" that a leading underscore
"denote[s] 'internal'" (or anything else but undefined behavior) is
revealed as a danger to themselves and others.

Now, I'll grant that large parts of X11 predate the C standards, but
that's no excuse for ignoring the problem or pretending it doesn't
exist.  There should be a plan in place for dealing with this sort of
thing.

cheers
-- 
Chris Waters           |  Pneumonoultra-        osis is too long
xtifr@debian.org       |  microscopicsilico-    to fit into a single
or xtifr@speakeasy.net |  volcaniconi-          standalone haiku



Reply to: