Fundamental Types¶
The following types are collectively called the fundamental types:
The
voidtypeThe scalar Boolean type
The scalar integer types
The scalar floating point types
Void Type {#void}¶
The type void contains no data and has a single unnamed value.
A function with return type void does not return a value.
Variables, arrays elements, or structure data members may not have type void.
Scalar Types {#scalar}¶
Boolean Type {#boolean}¶
Type bool is used to represent Boolean truth values: true and false.
The size of bool is target-defined. Similarly, the underlying bit patterns for true and false are
target-defined. The use of bool should be avoided when a specific in-memory layout of a data structure is
required. This includes data shared between different language targets even on the same device.
Integer Types {#integer}¶
The following integer types are defined:
Name |
Description |
|---|---|
|
8-bit signed integer |
|
16-bit signed integer |
|
32-bit signed integer |
|
64-bit signed integer |
|
8-bit unsigned integer |
|
16-bit unsigned integer |
|
32-bit unsigned integer |
|
64-bit unsigned integer |
All arithmetic operations on signed and unsigned integers wrap on overflow.
All target platforms support the int/int32_t and uint/uint32_t types. The support for other types depends on the target and target capabilities. See target platforms for details.
All integer types are stored in memory with their natural size and alignment on all target that support them.
Floating-Point Types {#floating}¶
The following floating-point type are defined:
Name |
Description |
Precision (sign/exponent/significand bits) |
|---|---|---|
|
16-bit floating-point number |
1/5/10 |
|
32-bit floating-point number |
1/8/23 |
|
64-bit floating-point number |
1/11/52 |
Rules for rounding, denormals, infinite values, and not-a-number (NaN) values are generally target-defined. IEEE 754 compliant targets adhere to the IEEE 754-2019 standard.
All targets support the float/float32_t type. Support for other types is target-defined. See
target platforms for details.
Alignment and data layout¶
The size of a Boolean type is targed-defined. All other fundamental types have precisely defined sizes.
All fundamental types are naturally aligned. That is, their alignment is the same as their size.
All fundamental types use little-endian representation.
All signed integers use two’s complement representation.
📝 Remark: Fundamental types in other languages are not always naturally aligned. In particular, the alignment of C type
uint64_ton x86-32 is typically 4 bytes.