[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:51:58AM -0700, Chris Waters wrote:
> 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.

OK, so let me dictate something on behalf of the XSF and X upstream and
make existing, long-accepted practice absolutely clear:

The use of a preceding underscore in functions, macros, variable names
and/or other symbols in X code denotes internalisation, and MUST NOT be
depended on by any other library.

Sure, we can't stop you using it. But you get to keep both pieces, just
like this bug report.

-- 
Daniel Stone                                                <daniels@debian.org>
Debian: the universal operating system                     http://www.debian.org

Attachment: signature.asc
Description: Digital signature


Reply to: