Colonel Kernel wrote:
Sometimes it's a very fine line between "language" and "library". In this case, I see nothing "platform-specific" per se about stdint.h...
What went into the language and what went into the library doesn't really have to do with platform- or architecture-specific. Fact is that extending the
library is much easier for all involved than extending the
language, including compatibility considerations. Hence, most of the things that were added after the initial K&R C were added to the
library - including bool and uint32_t.
Just to clarify, I'm not creating a C library for my OS, at least not in the sense of creating something consumable from user-mode. I've just started coding in the kernel itself, and I want language support, not libraries. (By language support, I basically mean auxiliary type definitions like bool, uint16_t, etc.).
Well, but that
is in the library, not the language. The
language defines char, short, int, long, and (in C99) long long, nothing else (as far as integers are concerned).
I am quite sure that <stdint.h> is part of the C99 standard.
Correct.
"section 7.18 of the C99 standard (ISO/IEC 9899:1999)"
Uh-huh.
If anyone out there has a copy of the C99 standard, can you please confirm...?
I can confirm that chapter 7 of the standard defines the library.
My understanding about how the standardization of libraries works comes mostly from the C++ world... There, I believe the STL is part of the language standard itself, but it is optional for a conforming implementation. I would expect C99 to work the same way...
That's not quite correct, not for C++ and not for C. An implementation can be either
freestanding or
hosted.
A
hosted implementation means the whole shebang: Language, library, runtime, initializing statics and globals, registering functions with atexit(), entering at int main() with stdout and stdin etc. etc. pp.
A
freestanding implementation doesn't have to provide any of the runtime support, but still has to support the language, and a defined subset of the library - in case of C99, that would be float.h, iso646.h, limits.h, stdarg.h, stdbool.h, stddef.h, and stdint.h.
Note, however, that this is still
the library. A compiler doesn't have to know
anything about the library. After all, you might want to exchange the glibc with newlib or the Dinkumware library, because they are faster / threadsafe / more precise in their maths, no? So, the compiler mustn't assume anything about the library.
There we are again. The Cross Compiler you built is a cross-
compiler. No library there.
So anything defined in chapter 7 of the standard needn't be there. If it
is, that's because the GCC implementors took some ("implementation-defined") liberties around the edges.
Hope I could clarify this now.