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


Groups > comp.lang.c > #62889

Re: About freestanding C

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: About freestanding C
Date 2015-05-31 14:14 -0700
Organization None to speak of
Message-ID <87eglwih4u.fsf@kst-u.example.com> (permalink)
References <c85af478-5e21-456f-9ac6-c2a054bea9da@googlegroups.com>

Show all headers | View raw


David Kleinecke <dkleinecke@gmail.com> writes:
> Many people are unaware of it but C comes in two forms. According to 
> clause 4 of the C90 standard (and, I assume, all the  later versions):
>
> The two forms of conforming implementation are hosted and freestanding. 
[...]

I'm sure many people are unaware of that, but I suspect most readers
here are quite familiar with the distinction.

[...]

> I do not know whether the standard means by the second sentence in 
> 5.1.2.1 that the reserved identifiers of 7.1.3 are not reserved in a 
> freestanding C implementation.

In the C90 standard, the first paragraph of 5.1.2.1 is:

    In a freestanding environment (in which C program execution
    may take place without any benetit of an operating system),
    the name and type of the function called at program startup
    are implementation-defined. There are otherwise no reserved
    external identitiers.  Any library tacilities available to a
    freestanding propram are implementation-defined.

Macro names are not "external identifiers", so freestanding C90
implementations are free to predefine macros whose names start
with two underscores or with an underscore and an uppercase letter.
But apparently identifiers defined in the standard headers (other
than the headers that are required for freestanding implementations)
and classes of identifiers like str* and mem* are not reserved for
C90 freestanding implementations.

That sentence does not appear in the C99 or C11 standard.  In C11,
5.1.2.1p1 is:

    In a freestanding environment (in which C program execution
    may take place without any benefit of an operating system),
    the name and type of the function called at program startup are
    implementation-defined. Any library facilities available to a
    freestanding program, other than the minimal set required by
    clause 4, are implementation-defined.

I'm not sure what the omission implies.  Personally, I'd try to avoid
reserved identifiers even when using a freestanding implementation,
simply because it's easy to do so and it avoids confusion.

-- 
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.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

About freestanding C David Kleinecke <dkleinecke@gmail.com> - 2015-05-31 12:27 -0700
  Re: About freestanding C Ian Collins <ian-news@hotmail.com> - 2015-06-01 08:48 +1200
  Re: About freestanding C Keith Thompson <kst-u@mib.org> - 2015-05-31 14:14 -0700
    Re: About freestanding C Philip Lantz <prl@canterey.us> - 2015-05-31 21:03 -0700
      Re: About freestanding C Keith Thompson <kst-u@mib.org> - 2015-05-31 23:50 -0700

csiph-web