C99
![](http://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/ISO-IEC-9899-1999-cover.png/180px-ISO-IEC-9899-1999-cover.png)
C99 is a modern dialect of the C programming language. It extends the previous version (C90) to make better use of available computer hardware and to better employ the latest advances in compiler technology.
Some extensions provide more convenient ways of expressing particular algorithm constructs. Others provide better control, for instance for numerical purposes, or for directing optimizations.
History
After ANSI produced the first official standard for the C programming language in 1989, which became an international standard in 1990, the C language specification remained relatively static for some time, while C++ continued to evolve, largely during its own standardization effort. Normative Amendment 1 created a new standard for C in 1995, but only to correct some details of the 1989 standard and to add more extensive support for international character sets. The standard underwent further revision in the late 1990s, leading to the publication of ISO/IEC 9899:1999 in 1999, which was adopted as an ANSI standard in May 2000. The language defined by that version of the standard is commonly referred to as "C99." The international C standard is maintained by the working group ISO/IEC JTC1/SC22/WG14.
Design
C99 is, for the most part, backward compatible with C89 but is stricter in some ways.
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:
- inline functions
- intermingled declarations and code: variable declaration is no longer restricted to file scope or the start of a compound statement (block)
- several new data types, including
long long int
, optional extended integer types, an explicit boolean data type, and acomplex
type to represent complex numbers - variable-length arrays
- support for one-line comments beginning with
//
, as in BCPL or C++ - new library functions, such as
snprintf
- new header files, such as
stdbool.h
,complex.h
, andinttypes.h
- type-generic math functions (
tgmath.h
) - improved support for IEEE floating point
- designated initializers
- compound literals
- support for variadic macros (macros with a variable number of arguments)
restrict
qualification allows more aggressive code optimization- universal character names, which allows user variables to contain other characters than the standard character set
Parts of the C99 standard are included in the proposed extensions to the C++ language known as TR1 and C++0x, including integer types, header files, and library functions. Variable-length arrays are not among these included parts because C++'s Standard Template Library already includes similar functionality.
Implementations
Most C compilers now have support for at least some of the features new to C99. However, there has been less support from vendors such as Microsoft that have mainly focused on C++.
Implementation | Level of support | Details | |
---|---|---|---|
AMD x86 Open64 Compiler Suite | Mostly | Has C99 support equal to that of GCC.[1] | |
Ch | Partial | Supports major C99 features.[2] | |
Clang | Mostly | Does not support C99 floating-point pragmas.[3] | |
C++ Builder | Mostly | ||
GCC | Mostly | As of June 2011[update] and GCC 4.6, 43 features have been completely implemented (6 suffer library issues), 1 feature is broken and 6 are missing.[4] | |
IBM C for AIX, V6 [5] and XL C/C++ V11.1 for AIX [6] | Full | ||
IBM Rational logiscope | Full | Until Logiscope 6.3, only basic constructs of C99 were supported. C99 is officially supported in Logiscope 6.4 and later versions.[7] | |
The Portland Group PGI C/C++ | Full | ||
Intel C++ compiler | Mostly | ||
Microsoft Visual Studio | No | As of Visual Studio 2010, there are no plans to support C99.[8][9] | |
Open Watcom | Partial | Implements the most-used parts of the standard. However, they are enabled only through an undocumented command-line switch.[10] | |
Pelles C | Mostly | Supports most C99 features. | |
Portable C compiler | Partial | Working towards becoming C99-compliant. | |
Sun Studio | Full[11] | ||
Tiny C Compiler | Mostly | Does not support complex numbers or variable length arrays.[12] The developers state that "TCC is heading toward full ISOC99 compliance".[13] |
Version detection
A standard macro __STDC_VERSION__
is defined with value 199901L
to indicate that C99 support is available. As with the __STDC__
macro for C90, __STDC_VERSION__
can be used to write code that will compile differently for C90 and C99 compilers, as in this example that ensures that inline
is available in either case (by replacing it with static
in C90 to avoid linker errors.)
#if __STDC_VERSION__ >= 199901L
/* "inline" is a keyword */
#else
# define inline static
#endif
Future work
Since ratification of the 1999 C standard, the standards working group has prepared technical reports specifying improved support for embedded processing, additional character data types (Unicode support), and library functions with improved bounds checking. Work continues on technical reports addressing decimal floating point, additional mathematical special functions, and additional dynamic memory allocation functions. The C and C++ standards committees have been collaborating on specifications for threaded programming.
As of 2007, work has begun in anticipation of another revision of the C standard, informally called "C1X". The C standards committee has adopted guidelines that should limit the adoption of new features that have not been tested by existing implementations.
It is likely that the standard gets
function, which was officially deprecated in response to a defect report concerning its unsafe interface design, will not be specified in the next revision of the C standard.[14]
See also
References
- ^ "x86 Open64". Developer.amd.com. 1989-04-01. Retrieved 2009-06-08.
- ^ "C/C++ interpreter Ch C99 features". SoftIntegration, Inc. 2008-02-15. Retrieved 2008-02-15.
- ^ "Clang Compiler User's Manual". Retrieved 2010-01-11.
- ^ "Status of C99 features in GCC". Free Software Foundation, Inc. 2011-04-25. Retrieved 2011-06-05.
- ^ http://www-01.ibm.com/common/ssi/cgi-bin/ssialias?infotype=an&subtype=ca&supplier=897&appname=IBMLinkRedirect&letternum=ENUS202-161
- ^ http://www-01.ibm.com/software/awdtools/xlcpp/aix/features/
- ^ http://www-01.ibm.com/support/docview.wss?uid=swg21408170
- ^ http://connect.microsoft.com/VisualStudio/feedback/details/485416/support-c99
- ^ http://msdn.microsoft.com/en-us/library/zb1574zs%28v=VS.100%29.aspx
- ^ "C99 compliance in Open Watcom". Retrieved 2009-03-11.
- ^ "Sun Studio 12: C Compiler 5.9 Readme". Sun Microsystems, Inc. 2007-05-31. Retrieved 2008-01-09.
- ^ http://bellard.org/tcc/tcc-doc.html#SEC7
- ^ http://bellard.org/tcc/
- ^ "Remove
gets()
". Registered document of ISO/IEC JTC1/SC22/WG14. 2009-10-29.; adopted by the committee as stated in "draft minutes of the October 2009 meeting" (PDF)., item 4.27.
Further reading
- Cheng, Harry (March 1, 2002). "C99 & Numeric computing". Dr. Dobb's Journal.
- Seebach, Peter (24 March 2004). "Open source development using C99". developerWorks. IBM.