C99 ( C9X during its development, formally ISO/IEC 9899:1999) is a past version of the C programming language open standard. It extends the previous version (C90) with new features for the language and the standard library, and helps implementations make better use of available computer hardware, such as IEEE 754-1985 floating-point arithmetic, and compiler technology. The C11 version of the C programming language standard, published in 2011, updates C99.
In particular, a declaration that lacks a type specifier no longer has int implicitly assumed. The C standards committee decided that it was of more value for compilers to diagnose inadvertent omission of the type specifier than to silently process legacy code that relied on implicit int. In practice, compilers are likely to display a warning, then assume int and continue translating the program.
C99 introduced several new features, many of which had already been implemented as extensions in several compilers:
Parts of the C99 standard are included in the current version of the C++ standard, including integer types, headers, and library functions. Variable-length arrays are not among these included parts because C++'s Standard Template Library already includes similar functionality.
On platforms with IEEE 754 floating point:
float tends to limit the risk of Round-off error affecting numerically unstable expressions (see IEEE 754 design rationale) and is the designed default method for x87 hardware, but yields unintuitive behavior for the unwary user; double was the default evaluation method originally used in K&R C, which promoted all floats to double in expressions; and [[long double]] is also commonly used and specifies a strict "evaluate to type" of the operands. (For gcc, FLT_EVAL_METHOD == 2 is the default on 32 bit x86, and FLT_EVAL_METHOD == 1 is the default on 64 bit x86-64, but FLT_EVAL_METHOD == 0 can be specified on x86-64 with option -mfpmath=387.) Before C99, compilers could round intermediate results inconsistently, especially when using x87 floating-point hardware, leading to compiler-specific behaviour; such inconsistencies are not permitted in compilers conforming to C99 (annex F).
double compute_fn(double z) { // 1
int main(void) {
#pragma STDC FENV_ACCESS ON // [2]
assert(FLT_EVAL_METHOD == 2); // [3]
if (isnan(z)) { // [4]
puts("z is not a number");
}
if (isinf(z)) {
puts("z is infinite");
}
long double r = 7.0 - 3.0 / (z - 2.0 - 1.0 / (z - 7.0 + 10.0 / (z - 2.0 - 2.0 / (z - 3.0)))); // [5, 6]
feclearexcept(FE_DIVBYZERO); // [7]
bool raised = fetestexcept(FE_OVERFLOW); // [8]
if (raised) {
puts("Unanticipated overflow.");
}
return r;
}
#ifndef __STDC_IEC_559__
puts("Warning: __STDC_IEC_559__ not defined. IEEE 754 floating point not fully supported."); // [9]
#endif
#pragma STDC FENV_ACCESS ON
#ifdef TEST_NUMERIC_STABILITY_UP
fesetround(FE_UPWARD); // [10]
#elif TEST_NUMERIC_STABILITY_DOWN
fesetround(FE_DOWNWARD);
#endif
printf("%.7g\n", compute_fn(3.0));
printf("%.7g\n", compute_fn(NAN));
return 0;
}
Footnotes:
/* "inline" is a keyword */
Historically, Microsoft has been slow to implement new C features in their Visual C++ tools, instead focusing mainly on supporting developments in the C++ standards. However, with the introduction of Visual C++ 2013 Microsoft implemented a limited subset of C99, which was expanded in Visual C++ 2015.
| Acorn C/C++ | The official documentation states that "most" compiler features are supported, along with "some" of the library functions. | |
| AMD x86 Open64 Compiler Suite | Has C99 support equal to that of GCC. | |
| cc65 | Full C89 and C99 support is not implemented, partly due to platform limitations (MOS Technology 6502). There is no support planned for some C99 types like _Complex and 64-bit integers (long long). | |
| Ch | Supports major C99 features. | |
| Clang | Supports all features except C99 floating-point pragmas. | |
| CompCert | A certified compiler, formally proved correct. Supports all features except C99 complex numbers and VLA, and minor restrictions on switch statements (no Duff's device). | |
| cparser | Supports C99 features. | |
| C++ Builder | ||
| Digital Mars | Lacks support for some features, such as | |
| GCC | , standard pragmas and IEEE 754/IEC 60559 floating-point support are missing in mainline GCC. Additionally, some features (such as extended integer types and new library functions) must be provided by the C standard library and are out of scope for GCC. GCC's 4.6 and 4.7 releases also provide the same level of compliance. Partial IEEE 754 support, even when the hardware is compliant: some compiler options may be needed to avoid incorrect optimizations (e.g., __STDC_VERSION__ and 199901L), but full support of directed rounding modes is missing even when __STDC__ is used. | |
| Green Hills Software | ||
| IBM C for AIX, V6 and XL C/C++ V11.1 for AIX | ||
| IBM Rational logiscope | Until Logiscope 6.3, only basic constructs of C99 were supported. C99 is officially supported in Logiscope 6.4 and later versions. | |
| The Portland Group PGI C/C++ | ||
| IAR Systems Embedded Workbench | Does not support UCN (universal character names). Compiler for embedded targets, such as ARM, Coldfire, MSP430, AVR, AVR32, 8051, ... No x86 targets. | |
| Intel C++ compiler | ||
| Microsoft Visual C++ | Visual C++ 2012 and earlier did not support C99. Visual C++ 2013 implements a limited subset of C99 required to compile popular open-source projects. Visual C++ 2015 implements the C99 standard library, with the exception of any library features that depend on compiler features not yet supported by the compiler (for example, Visual C++ 2019 (16.6) adds opt-in support for a C99 conformant preprocessor. | |
| Open Watcom | Implements the most commonly used parts of the standard. However, they are enabled only through the undocumented command-line switch "-za99". Three C99 features have been bundled as C90 extensions since pre-v1.0: C++ style comments (//), flexible array members, trailing comma allowed in enum declaration. | |
| Pelles C | Supports all C99 features. | |
| Portable C compiler | Working towards becoming C99-compliant. | |
| Sun Studio | ||
| The Amsterdam Compiler Kit | A C99 frontend is currently under investigation. | |
| Tiny C Compiler | Does not support complex numbers.According to the project's TODO list complex types are the only missing C99 feature. Variable Length Arrays have been added in TCC 0.9.26 [4] Variable Length Arrays are supported but not as arguments in functions. The developers state that "TCC is heading toward full ISOC99 compliance". | |
| vbcc |
The next revision of the C standard, C11, was ratified in 2011. The C standards committee adopted guidelines that limited the adoption of new features that have not been tested by existing implementations. Much effort went into developing a memory model, in order to clarify and to support threaded programming.
|
|