Overview

The bottom of the type hierarchy consists of simple types. This comprises the primitive types that all other types are either based off of or derived from.

SignedUnsigned32-bit64-bit
-bool11
signed charunsigned char11
shortunsigned short22
intunsigned44
longunsigned long48
long longunsigned long long88
RealComplex32-bit64-bit
float-44
double-88
long double---
-float complex44
-double complex88
-long double complex--

Integers

Narrow types cannot be used directly in arithmetic. Instead they are first promoted to a wider type. On almost every system, this promotion will be to a signed int of the same value, regardless of the signedness of the narrow type itself.

Character Types

The three types char, signed char, and unsigned char are collectively called the character types. The implementation defines char to have the same range, representation, and behavior as either signed char or unsigned char, but is considered incompatible with both. That is, it is a distinct type in the eyes of the type system.

Unsigned Integers

NameNarrowRankMinimum Width
boolYes01
char (maybe)Yes1-
unsigned charYes18
unsighed shortYes216
unsigned intNo316
unsigned longNo432
unsigned long longNo564

Signed Integers

NameNarrowRankMinimum Width
char (maybe)Yes1-
signed charYes18
signed shortYes216
signed intNo316
signed longNo432
signed long longNo564
float---
double---
long double---

Literals

Negative integer literals are typed in a counterintuitive way. When the compiler sees a number of form -X, the type of X is determined before being negated. Promotion follows the first fit rule described as follows:

DecimalOct/Hex
intint
longunsigned
long longlong
-unsigned long
-long long
-unsigned long long

Integer constants can be made a certain signedness or type by using the following suffixes:

SuffixType
Uunsigned
Llong
LLlong long
ULLunsigned long long

Integer Constant Expressions

An integer constant expression (ICE) is a compile-time integer value. Its value must be determinable at compile time (e.g. no function calls are permitted), and also no evaluation of an object must participate as an operand.

Floating Point

Literals

Floating-point constants can be made a certain type by using the following suffixes:

SuffixType
Ffloat
Llong double

Exact-Width Integer Types

The stdint.h library contains exact-width integer types. These are aliases to types that represent an exact width and sign representation:

  • If the type uintN_t is provided, it is an unsigned integer type with exactly bits of width and precision.
  • If the type intN_t is provided, is is signed, with two’s complement representation, has a width of exactly bits and a precision of .

The C standard says these typedefs must be defined if they can be satisfied. Otherwise they may not exist.

Enumerated Types

An enum is a mapping of identifiers with integer values. They have general form:

enum optional_tag {
  type1 ident1;
  ...
  typeN identN;
} optional_var1 ... optional_varN;

Bibliography