Chapter 3
Types

All variables have a type. Free Pascal supports the same basic types as Turbo Pascal, with some extra types from Delphi as well as some of its own.

The programmer can declare his own types, which is in essence defining an identifier that can be used to denote this custom type when declaring variables further in the source code. Declaring a type happens in a Type block (section 16.5, page 900), which is a collection of type declarations, separated by semicolons:

_________________________________________________________________________________________________________
Type declaration

--type declaration- identifier-=  -type -|--------------;---------------
                                  -hint directives-
___________________________________________________________________

There are eight major kinds of types:

_________________________________________________________________________________________________________
Types

--type ----simple type--------------------------------------------
        --string type--|
        -structured type -|
        --pointer type--|
        |procedural type-|
        |-generic type---|
        |specialized type-|
        ---type alias-----
___________________________________________________________________

Each of these cases will be examined separately.

 3.1 Base types
  3.1.1 Ordinal types
  3.1.2 Real types
 3.2 Character types
  3.2.1 Char or AnsiChar
  3.2.2 WideChar
  3.2.3 Other character types
  3.2.4 Single-byte String types
  3.2.5 Multi-byte String types
  3.2.6 Constant strings
  3.2.7 PChar – Null terminated strings
  3.2.8 String sizes
 3.3 Structured Types
  3.3.1 Arrays
  3.3.2 Record types
  3.3.3 Set types
  3.3.4 File types
 3.4 Pointers
 3.5 Forward type declarations
 3.6 Procedural types
 3.7 Variant types
  3.7.1 Definition
  3.7.2 Variants in assignments and expressions
  3.7.3 Variants and interfaces
 3.8 Type aliases
 3.9 Managed types