This page lists 53 features that were new in C99 (i.e they are in C99 but not C89). Are all of these features also in C++? Even C++98?
If not, which of the features are in C++ and which are not?
C99 is a standard of the C language published by ISO and adopted by ANSI in around 1999. GNU C is just an extension of c89,while some features of c99 are also added,but in entirety it is different from c99 standard so when compiling in gcc we have to enter -std=c99 which is already mentioned in the other answers.
Important Features of C99 These new features include: Some features are like extensions to C90 offered by GNU compiler such as macros with a variable number of arguments. C99 allows the use of sophisticated numbers and designated initializers. Restricted pointers are also added in C99.
C99 is a step ahead in the evolution of ANSI C. It incorporates elegant features like single line comments, boolean data types and larger size data types. C99 also supports code optimization through restricted pointer usage and supports inline functions.
C99 (previously known as C9X) is an informal name for ISO/IEC 9899:1999, a past version of the C programming language standard.
The following C99 (ISO 9899:1999) features are fully supported by C++ (ISO 14882:2017):
(though library headers will be <cname>
rather than <name.h>
:
- wide character library support in
<wchar.h>
and<wctype.h>
(originally specified in ISO/IEC 9899:1990/Amd.1:1995)- type-generic math macros in
<tgmath.h>
- the long long int type and library functions
- extended integer types
- increased minimum translation limits
- additional floating-point characteristics in
<float.h>
- remove implicit int
- reliable integer division
- universal character names (\u and \U)
- extended identifiers
- hexadecimal floating-point constants and %a and %A printf/scanf conversion specifiers
- // comments
- specified width integer types and corresponding library functions in
<inttypes.h>
and<stdint.h>
- remove implicit function declaration
- preprocessor arithmetic done in intmax_t/uintmax_t
- mixed declarations and statements
- new block scopes for selection and iteration statements
- integer constant type rules
- integer promotion rules
- the vscanf family of functions in
<stdio.h>
and<wchar.h>
- additional math library functions in
<math.h>
- treatment of error conditions by math library functions (math_errhandling)
- floating-point environment access in
<fenv.h>
- IEC 60559 (also known as IEC 559 or IEEE arithmetic) support
- trailing comma allowed in enum declaration
- %lf conversion specifier allowed in printf
- inline functions
- the snprintf family of functions in
<stdio.h>
- idempotent type qualifiers
- empty macro arguments
- additional predefined macro names
- _Pragma preprocessing operator
- standard pragmas
__func__
predefined identifier- va_copy macro
- additional strftime conversion specifiers
- LIA compatibility annex
- deprecate ungetc at the beginning of a binary file
- remove deprecation of aliased array parameters
- conversion of array to pointer not limited to lvalues
- relaxed constraints on aggregate and union initialization
- relaxed restrictions on portable header names
- return without expression not permitted in function that returns a value (and vice versa)
- macros with a variable number of arguments
The following C99 features have similar use in C++, but there are implementation differences and the languages are not code compatible:
- restricted character set support via digraphs and
<iso646.h>
(originally specified in ISO/IEC 9899:1990/Amd.1:1995)- more precise aliasing rules via effective type
- complex (and imaginary) support in
<complex.h>
- boolean type in
<stdbool.h>
- new structure type compatibility rules (tag compatibility)
The following C99 features are not supported by C++:
- restricted pointers
- variable length arrays
- flexible array members
- static and type qualifiers in parameter array declarators
- compound literals
- designated initializers
Flexible array members are not part of any C++ standard (and the dynarray proposal was not adapted in C++). And there are many other less used C99 features which are not in C++.
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