James Kuyper
2025-01-22 03:50:38 UTC
standard says
"__STDC_HOSTED__ The integer constant 1 if the implementation is a
hosted implementation or the
integer constant 0 if it is not."
What is a hosted implementation?
"A _strictly conforming program_ shall use only those features of the"__STDC_HOSTED__ The integer constant 1 if the implementation is a
hosted implementation or the
integer constant 0 if it is not."
What is a hosted implementation?
language and library specified in this document.3) It shall not produce
output dependent on any unspecified, undefined, or
implementation-defined behavior, and shall not exceed any minimum
implementation limit." (4p5)
"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 specified in the library clause (Clause 7) is confined to the
contents of the standard headers <float.h>, <iso646.h>, <limits.h>,
<stdalign.h>, <stdarg.h>, <stdbit.h>, <stdbool.h>, <stddef.h>,
<stdint.h>, and <stdnoreturn.h>. Additionally, a conforming freestanding
implementation shall accept any strictly conforming program where:
— the features specified in the header <string.h> are used, except the
following functions:
strdup, strndup, strcoll, strxfrm, strerror; and/or,
— the selected function memalignment from <stdlib.h> is used." (4p6)
Several of the terms in those clauses are in italics, an ISO convention
which indicates that the sentence in which the italicized term occurs
constitutes the official definition of that term. I've indicated where
the italics are by bracketing them with underscores.
Thus, a conforming hosted implementation of C supports all of the
mandatory features of C. A freestanding implementation of C implements
the full C language, but is not required to implement all of the C
standard library. It is only required to implement those parts described
by the specified standard headers, and is not required to implement the
specified functions from the <string.h> and <stdlib.h> headers.