Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

c

c99

c89

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?

like image 704
user200783 Avatar asked Nov 28 '17 05:11

user200783


People also ask

Is C99 same as C?

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.

Which of the following feature added to the C99 standard?

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.

What is C99 used for?

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.

Is C99 C or c++?

C99 (previously known as C9X) is an informal name for ISO/IEC 9899:1999, a past version of the C programming language standard.


2 Answers

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
like image 78
2 revs Avatar answered Sep 28 '22 01:09

2 revs


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

like image 20
Basile Starynkevitch Avatar answered Sep 28 '22 01:09

Basile Starynkevitch