How universally is the C99 standard supported in today's compilers? I understand that not even GCC fully supports it. Is this right?
Which features of C99 are supported more than others, i.e. which can I use to be quite sure that most compilers will understand me?
C99 is a standard of the C language published by ISO and adopted by ANSI in around 1999.
C99 is the C standard ratified by the ANSI and ISO standardizaion groups. It presents a significant amount of changes to the C language. These changes are the result of sibling competition between C and C++. The initial version of C is named after Kernighan and Ritchie.
C99 is substantially completely supported as of GCC 4.5 (with -std=c99 -pedantic-errors used; -fextended-identifiers also needed to enable extended identifiers before GCC 5), modulo bugs and floating-point issues (mainly but not entirely relating to optional C99 features from Annexes F and G).
If you want to write portable C code, then I'd suggest you to write in C89 (old ANSI C standard). This standard is supported by most compilers.
The Intel C Compiler has very good C99 support and it produces fast binaries. (Thanks 0x69!)
MSVC supports some new features and Microsoft plan to broaden support in future versions.
GCC supports some new things of C99. They created a table about the status of C99 features. Probably the most usable feature of C99 is the variable length array, and GCC supports it now. Clang (LLVM's C fronted) supports most features except floating-point pragmas.
Wikipedia seems to have a nice summary of C99 support of the compilers.
Someone mentioned the Intel compiler has C99 support. There is also the Comeau C/C++ compiler which fully supports C99. These are the only ones I'm aware of.
C99 features that I do not use because they are not well supported include:
C99 features that I regularly use that seem to be pretty well supported (except by Microsoft):
stdint.h
snprintf()
- MS has a non-standard _snprintf()
that has serious limitations of not always null terminating the buffer and not indicating how big the buffer should beTo work around Microsoft's non-support, I use a public domain stdint.h
from MinGW (that I modified to also work on VC6) and a nearly public domain snprintf()
from Holger Weiss
Items that are not supported by Microsoft, but will still use on other compilers depending on the project include:
_Pragma()
- this makes pragmas much more usableFor gcc, there is a table with all supported features. It seems to be that the biggest thing missing are variable-length arrays. Most of the other missing features are library issues rather than language features.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With