Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Common types

&pagelevel(4)&pagelevel

In order to use data and functions in C and C++, they must have the same or comparable types. C++ contains the same set of basic data types as C; however, since C++ is a true superset of C, it also contains more types than C.

The following C++ types may be used for linkage between C++ and other languages:

  • fundamental types: char, short, int, long, long long, float, double, long double, void

  • qualifiers: unsigned, const, volatile

  • pointers to common types

  • arrays of common types (passed as pointers)

  • structures and unions
    These must not contain the following components in C++: member functions, constructors, destructors, base classes, and access specifiers. The structure and union components must have common types, i.e. must be syntactically identical.

  • simple enumerations

  • functions with common argument and result types
    Ellipses (...) are permitted.

The following types must not be used if linkage to other languages is required:

  • reference types

  • pointers to members of classes, unions, or structures

  • classes

  • structures and unions containing member functions, constructors, destructors, base classes, or access specifiers

  • enumerations with explicit type or scope: enum E1 : int; enum struct E2;
  • types defined locally in a class
  • member functions

  • templates

  • std::nullptr_t
  • bool
  • _Complex, _Imaginary (a C11 feature)
  • varable length arrays (a C11 feature)