Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #62880 > unrolled thread
| Started by | David Kleinecke <dkleinecke@gmail.com> |
|---|---|
| First post | 2015-05-31 12:27 -0700 |
| Last post | 2015-05-31 23:50 -0700 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.lang.c
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
| From | David Kleinecke <dkleinecke@gmail.com> |
|---|---|
| Date | 2015-05-31 12:27 -0700 |
| Subject | About freestanding C |
| Message-ID | <c85af478-5e21-456f-9ac6-c2a054bea9da@googlegroups.com> |
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. A conforming hosted implementation shall accept any strictly conforming program. A conforming freestanding implementation shall accept any strictly conforming program in which the use of the features in the library clause (clause 7) is confined to the contents of the standard headers <float.h>, <limits.h>, <stdarg.h> and <stddef.h>. (4) Two execution environments are defined: freestanding and hosted. (5.1.2) In a frestanding 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 implentation-defined. There are otherwise no reserved external identifiers. Any library facilities available to a freestanding program are implentation-defined. The effect of program termination in a freestanding environment is implementation-defined. (5.1.2.1) Headers <float.h> and <limits.h> define a lot of maximum and minimum values for integers and a more complicated set for reals. Header <stdarg.h> provides the macros needed to read the arguments when a function is elliptic and <stddef.h> defines a few useful macros like NULL. Clearly freestanding V is quite stripped down - but I think it is the world of embedded C coding. It seems to me that what I have been calling "core C" is very similar to "freestanding C". I am going to stick to "code C" for the moment but this indentification gives "core C" a much more respectable position in respect to hosted C (which seems to generally be what "C language" means to people). 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.
[toc] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2015-06-01 08:48 +1200 |
| Message-ID | <ct1adqFrf5eU1@mid.individual.net> |
| In reply to | #62880 |
David Kleinecke wrote: > 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. > A conforming hosted implementation shall accept any strictly conforming > program. A conforming freestanding implementation shall accept any > strictly conforming program in which the use of the features in the > library clause (clause 7) is confined to the contents of the standard > headers <float.h>, <limits.h>, <stdarg.h> and <stddef.h>. (4) The list of freestanding headers is expanded in the current standard. > 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. The sentence "There are otherwise no reserved external identifiers." does not appear in the current standard. -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2015-05-31 14:14 -0700 |
| Message-ID | <87eglwih4u.fsf@kst-u.example.com> |
| In reply to | #62880 |
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"
[toc] | [prev] | [next] | [standalone]
| From | Philip Lantz <prl@canterey.us> |
|---|---|
| Date | 2015-05-31 21:03 -0700 |
| Message-ID | <MPG.2fd5795814c9cee132@news.eternal-september.org> |
| In reply to | #62889 |
Keith Thompson wrote: > > 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 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. To me, the sentence in question (C90, 5.1.2.1p1, second sentence) implies that the name of the function called at program startup is a reserved identifier. I speculate that that was not what they meant, so they removed the sentence, to avoid the implication. (I don't think 'main' is a "reserved identifier" in a hosted implementation, is it?) C11, 7.1.3p2 says "No other identifiers are reserved" (where "other" refers to the list in 7.1.3p1). I don't know whether that sentence was there in C90 (I don't have it handy at the moment); perhaps it was inserted in C99 when the second sentence in 5.1.2.1p1 was removed? Philip
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2015-05-31 23:50 -0700 |
| Message-ID | <87siabhqhh.fsf@kst-u.example.com> |
| In reply to | #62899 |
Philip Lantz <prl@canterey.us> writes:
> Keith Thompson wrote:
>> 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 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.
[...]
>> That sentence does not appear in the C99 or C11 standard.
[...]
>> 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.
>
> To me, the sentence in question (C90, 5.1.2.1p1, second sentence)
> implies that the name of the function called at program startup is a
> reserved identifier. I speculate that that was not what they meant, so
> they removed the sentence, to avoid the implication. (I don't think
> 'main' is a "reserved identifier" in a hosted implementation, is it?)
That's plausible.
> C11, 7.1.3p2 says "No other identifiers are reserved" (where "other"
> refers to the list in 7.1.3p1). I don't know whether that sentence was
> there in C90 (I don't have it handy at the moment); perhaps it was
> inserted in C99 when the second sentence in 5.1.2.1p1 was removed?
Yes, the "No other identifiers are reserved" sentence is in C90.
--
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"
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c
csiph-web