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

Characters

Type char is special since it can be signed or unsigned depending on platform. Keep in mind regardless of its signedness, it is still considered a distinct type from both the unsigned char and signed char type.

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.

Unsigned

These correspond to nonnegative integer values.

NameNarrowRank
boolYes0
char (maybe)Yes1
unsigned charYes1
unsighed shortYes2
unsigned intNo3
unsigned longNo4
unsigned long longNo5

Signed

These correspond to possibly negative integer values.

NameNarrowRank
char (maybe)Yes1
signed charYes1
signed shortYes2
signed intNo3
signed longNo4
signed long longNo5
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 forced to be unsigned or to be a type with minimal width by using the following suffixes:

SuffixType
Uunsigned
Llong
LLlong long
ULLunsigned long long

Floating Point

Literals

Floating-point constants can be forced to be a type with minimal width by using the following suffixes:

SuffixType
Ffloat
Llong double

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

  • “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.
  • Van der Linden, Peter. Expert C Programming: Deep C Secrets. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.