Type | Base Type | Minc | Maxc | Constantsd |
chara | integer | 0 | 255 | 32 |
signed char | integer | -128 | 127 | 32 |
unsigned char | integer | 0 | 255 | 32 |
shortb | integer | -32768 | 32767 | 32 |
unsigned short | integer | 0 | 65536 | 32 |
inta,b | integer | -231 | 231-1 | 32 |
unsigned int | integer | 0 | 232-1 | 32U |
longb | integer | -231 | 231-1 | 32L |
unsigned long | integer | 0 | 232-1 | 32UL |
floata | floating point | 6/-38 | 6/38 | 3.7F |
double | floating point | 15/-308 | 15/308 | 3.7 |
long doublea | floating point | 15/-308 | 15/308 | 3.7L |
aThe most common definition is given, but might differ for other compilers.
bThe preceeding keyword signed (and the succeding keyword int for short and long types) is optional
cFor floating point numbers the two numbers are the number of digits (precission) and the exponent (of powers in 10). The minimum is here the smallest possible number, which are non-zero. Smaller numbers will raise the underflow exception.
dLiteral constants, when used in the source text. The minimal integer constant is of type signed integer, when not overridden by the suffix 'L' or 'U'.
Type | Comment |
bool | bool is equivalent to the char type, which predefined compiler definitions of true as 1 and false as 0. |
Pointers | Each data type can have a pointer associated with. Pointers don't have a keyword, but are marked by a preceeding asterix in the variable and function declaration/definition. Most compilers supplies the predefined constant NULL, which is equivalent to 0. |
void | Only allowed in function declaration/definition to indicate that the function has no return type or in case of a returning pointer that the pointer is not associated to a specific data type (e.g. malloc() is of type void *) |
Aliases | Aliases to existing data types can be defined with the typedef command outside a function block. (Example: typedef int error_number;) |
Structs | Combination of existing data type to a combined data type. Typically definition of structs are combined with typedef instructions to avoid the struct keyword in varable declaration. |
Enumeration | A list of names associated with an ascending series of integers. The definition is identical to structs (e.g. enum day {sun,mon,tue,wed,thue,fri,sat};), except that the curly brackets contains only the name associated with an ascending list, starting from zero. |
Prefix | Comment |
const | Indicates that a variable is constant and cannot be changed. Allows for better optimization |
register | Stores variable in internal memory of CPU chip for faster access. Not recommended because compilers are doing a better job with optimizations. |
volatile | Exclude certain optimzation if the content and memory location is sensitive for the execution (e.g. when the program is relying on low level input from external programs or hardware) |
extern | Indicates global variables in include files that they are declared but that the initial value is given somewhere else in the source text (e.g. a different source file). |
static | Preserves the content of variables of function to the next call of that function. |
struct | Indicates that the following data type is a struct. Is often avoided by making an alias to the struct definition with the typedef command. |
enum | Indicates that the following data type is an enumeration. Is often avoided by making an alias to the enumeration definition with the typedef command. |