How would compilers implementing the freestanding portion of each different standard below have to differ? What would be the fewest number of modes (specified by command line flags, for example) required to support all of them?
- ISO/IEC 9899:1990
- ISO/IEC 9899:1990 + ISO/IEC 9899 TCOR1
- ISO/IEC 9899:1990 + ISO/IEC 9899 TCOR1 + ISO/IEC 9899 AM1
- ISO/IEC 9899:1990 + ISO/IEC 9899 TCOR1 + ISO/IEC 9899 AM1 + ISO/IEC 9899 TCOR2
- ISO/IEC 9899:1999
- ISO/IEC 9899:1999 + ISO/IEC 9899:1999 Cor. 1:2001(E)
- ISO/IEC 9899:1999 + ISO/IEC 9899:1999 Cor. 1:2001(E) + ISO/IEC 9899:1999 Cor. 2:2004(E)
- ISO/IEC 9899:1999 + ISO/IEC 9899:1999 Cor. 1:2001(E) + ISO/IEC 9899:1999 Cor. 2:2004(E) + ISO/IEC 9899:1999 Cor. 3:2007(E)
- ISO/IEC 9899:2011
The TCs (technical corrigenda or technical corrections) should be treated as part of the corresponding base standard. So, you really have 4 possible standards to deal with:
The Amendment 1 for C90 added new headers and functions for wide character and multi-byte character sets, so it contained truly new standard material. The technical corrigenda fix issues in the standard wording, clarifying what needs to be clarified, and correcting technical errors in the document.
So, I would suggest that those four modes would be sufficient:
-std=c90
-std=c95
-std=c99
-std=c11
Or, if we are going to pay attention to the mistakes that led to the Y2K problems, then:
-std=c1990
-std=c1995
-std=c1999
-std=c2011
(One advantage of this is that the newest standard has the highest number once more!)
For freestanding implementations, there are few differences in the four headers that are required:
<stddef.h>
<limits.h>
<float.h>
<stdarg.h>
There was an extra macro/function,
va_copy()
, added to<stdarg.h>
in C99.Otherwise, the main changes occurred in the core language in C99 - things like the new types (
long long
), new initialization notations, and VLAs, and so on. From this perspective, AM1 (C95) didn't change anything for a freestanding implementation (unless digraphs were added then) because the main changes were in new headers that are not required in a freestanding implementation.Hosted implementations face many more issues because the library support was fairly extensively modified between C90 and C99.
I'm not aware of any backwards compatibility issues for freestanding as opposed to hosted implementations. With C99, the 'implicit
int
' rules are officially gone - you should declare functions before using them and the return type should be explicitlyint
(so, for example, a simplemain()
is no longer officially valid; you should writeint main()
or, better,int main(void)
or similar). But these are general changes between C90 (C95) and C99 - not peculiar to freestanding implementations. (And yes, I am aware that a freestanding implementation need not require a functionmain()
as the start point.) If your code is 'good' and has functions declared or defined with prototypes before use and no implicitint
types (and all functions defined using prototype notation would be strongly recommended), then what was good for a C90 freestanding program will work for C99 or C11.