user200783
user200783

Reputation: 14348

Are all of the features of C99 also in C++?

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?

Upvotes: 14

Views: 1356

Answers (2)

Lundin
Lundin

Reputation: 213892

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

Upvotes: 29

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++.

Upvotes: 3

Related Questions