Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c > #1865

Re: Reserved Identifiers

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.std.c
Subject Re: Reserved Identifiers
Date 2013-01-19 15:28 -0800
Organization None to speak of
Message-ID <lnehhg92ho.fsf@nuthaus.mib.org> (permalink)
References <kc0oon$i0t$1@dont-email.me> <n9ednUPDD9h732fNnZ2dnUVZ_vmdnZ2d@earthlink.com> <kdegai$ruc$1@dont-email.me>

Show all headers | View raw


Shao Miller <sha0.miller@gmail.com> writes:
[...]
> Suppose my standard header has an #include guard __STDIO_H.  The 
> person's argument was that this reserved identifier does not appear in 
> the Standard, so it should not be #defined in a standard header.

The person is clearly mistaken.

N1570 7.1.3p1:

    Each header declares or defines all identifiers listed in its
    associated subclause, and optionally declares or defines identifiers
    listed in its associated future library directions subclause and
    identifiers which are always reserved either for any use or for use
    as file scope identifiers.

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

    -- [...]

__STDIO_H is an identifier that's always reserved for any user.
<stdio.h> (I presume that's the header you're referring to) is part of
the implementation.  That's *exactly* the context for which it's
reserved.  (There are other contexts as well.)  The standard quite
explicitly grants permission for such identifiers to be defined in
standard headers.

[...]

> Essentially the argument was not that reserved identifiers cannot be 
> used by an implementation (such as the _BUILTIN_abs example in a 
> foot-note), but that such identifiers must not be declared/defined in a 
> standard header.  I've tried to argue against that position by saying 
> that an implementation _does_ have freedom to declare/define such 
> identifiers in a standard header, because that is outside of the context 
> in which these identifiers are "reserved for any use".

No, it's because it's *inside* the context *for which they're reserved*.

[...]

> Maybe a way to re-state the opposing position is: What makes us think 
> that an implementation can declare/define any identifier that has the 
> form of a reserved identifier, in a standard header?

We know because the standard clearly says so.

>                                                       How do we know 
> that all such identifiers are not reserved for future Standardization, 
> when discussing the context of declarations/definitions in a standard 
> header?

They *are* reserved for future standardization.  A future standard
could, in principle, make __STDIO_H a new keyword.  If it did so,
then that particular implementation of <stdio.h> would become
non-conforming.  Correcting that non-conformance would be a simple
matter of choosing a different identifier.

There is no implication that a given copy of <stdio.h> will
continue to conform without modification to future standards.
A conforming C90 <stdio.h> is not a conforming C99 <stdio.h>,
at least not without some preprocessor trickery.  Naturally, an
implementation has to be updated to conform to the new standard.

If you follow the rules in writing your own code (code that's not part
of the C implementation), you most likely *won't* have to modify your
code to make it conform to the new standard.  (This isn't always the
case; gets() is gone, there are new keywords that weren't previously
reserved, and so on.)

If you define __STDIO_H in your own code, your code's behavior is
already undefined.  This hypothetical new standard would cause your
code to behave differently.  Again, this violates no guarantee.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.std.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Reserved Identifiers Shao Miller <sha0.miller@gmail.com> - 2013-01-02 02:48 -0500
  Re: Reserved Identifiers Jonathan Leffler <jleffler@earthlink.net> - 2013-01-18 22:53 -0800
    Re: Reserved Identifiers Shao Miller <sha0.miller@gmail.com> - 2013-01-19 11:06 -0500
      Re: Reserved Identifiers Keith Thompson <kst-u@mib.org> - 2013-01-19 15:28 -0800
        Re: Reserved Identifiers Shao Miller <sha0.miller@gmail.com> - 2013-01-20 16:57 -0500
          Re: Reserved Identifiers Keith Thompson <kst-u@mib.org> - 2013-01-20 19:52 -0800
      Re: Reserved Identifiers Bart van Ingen Schenau <bart@ingen.ddns.info.invalid> - 2013-01-20 10:29 +0000
        Re: Reserved Identifiers Shao Miller <sha0.miller@gmail.com> - 2013-01-20 17:06 -0500
          Re: Reserved Identifiers Bart van Ingen Schenau <bart@ingen.ddns.info.invalid> - 2013-01-21 10:56 +0000
            Re: Reserved Identifiers Shao Miller <sha0.miller@gmail.com> - 2013-01-21 18:24 -0500

csiph-web