liveBook · Manning

Basic type

As explained in Modern C

A base type is the type from which a C derived type is formed or the type of the individual items that compose a C array.

Array elements have a base type

double a[4]; signed b[N]; The four elements of a are double objects, while the elements of b are signed objects. In a multidimensional declaration such as double C[M][N], C[0] is an array and C[0][0] is a double object. section 6.1.1

A basic type is one of C’s starting types for constructing derived types. Its first specification level uses keywords such as signed, int, and double; a second level uses semantic types supplied by headers, such as size_t and bool. Basic types represent unsigned integers, signed integers, real floating-point numbers, or complex floating-point numbers, with types differing in precision and permitted value range. section 5.2

Important rules distinguish basic types from their use in expressions and declarations:

  • char represents printable characters and may be signed or unsigned depending on the platform; bool represents false and true. section 5.2
  • Narrow integer types do not participate directly in arithmetic; before arithmetic, they are promoted to signed int. section 5.2
  • An array’s base type may itself be an array, producing a multidimensional array; read nested declarations from the inside out. section 6.1.1
  • Every pointer type is derived from a base type, and pointers with distinct base types are distinct types. section 12.0
Table 5.1. Base types according to the four main type classes. Types with a gray background don’t allow for arithmetic; they are promoted before doing arithmetic. Type char is special since it can be unsigned or signed, depending on the platform. All types in this table are considered to be distinct types, even if they have the same class and precision. (view table figure)

Class

Systematic name

Other name

Rank

Integers Unsigned _Bool bool 0
unsigned char 1
unsigned short 2
unsigned int unsigned 3
unsigned long 4
unsigned long long   5
[Un]signed char 1
  signed char 1
  signed short short 2
Signed signed int signed or int 3
  signed long long 4
  signed long long long long 5
Floating point Real float    
double    
long double    
Complex float _Complex float complex
double _Complex double complex
long double _Complex long double complex

Compare the four main classes of C base types, their alternate spellings, ranks, and the types promoted before arithmetic. section 5.2

How Modern C covers it

How deep it goes
Classifies integer and floating-point types, explains promotions, and stops short of detailed derived-type construction.
Examples
Uses double and signed arrays, multidimensional declarations, character and Boolean types, and a classification table.
What you can do after
Evaluate C declarations by identifying their basic type, array element type, pointer base type, and arithmetic promotion behavior.
How it connects
Connects basic types with derived types, arrays, pointers, arithmetic expressions, precision, and integer promotion.

Also explained in

Compare how 2 books explain basic type →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.