Richard Heathfield said:
Jean-Pierre Mestre said:
Yes. It's called "the ISO C Standard" or, more formally, ISO/IEC 9899.
Just about any C compiler you are likely to come across conforms to the
1990 version of that Standard. (There is a later version, 9899:1999,
but it is not (yet) recognised by all, or indeed more than a handful
of, compilers.)
yes.
C90 is good, yes...
C99 contains a few features that look particularly problematic (dynamic
arrays and so on...).
still, should work pretty good as a reference for writing portable code (to
what extent what one writes can be made portable...).
the standard explains more than a few things, but stops well short of a
complete explanation (for example, of the exact calling conventions, data
representations, ... employed by an architecture, which may be particularly
relevant for more involved projects).
another approach (though better when combined with the standards, so one
knows more what is and is not standard) is to take some specific
implementation (say, gcc), and using this as a general reference
implementation ('how things work' and similar questions). this is generally
what I have done. how and what is done in gcc is something I personally find
particularly relevant to my own efforts.
my case, I have a compiler, it supports a subset of C (and also has a few
extensions). well, I don't have working static declarations and inline
functions as of yet, but I do have builtin geometric vectors and
quaternions, and other misc extension features...
note: the purpose of my compiler is not to compete with gcc, but to fill a
nice currently left void by gcc, that of being an at-runtime compiler (IMO,
a lot more powerful and useful than a typical script VM).
now, if in my compiler, I go and write code making use of a bunch of vector
and quaternion math using my extensions, well, then, it is not portable. I
still decided having them was worthwhile though.
also, apparently, unlike gcc I went and implemented imaginary types, having
failed to notice that gcc did not until generally afterwards. oh well...
or such...