_________________________________________________________________________________________________________
Constant declaration
___________________________________________________________________
The compiler must be able to evaluate the expression in a constant declaration at compile time. This means that most of the functions in the Run-Time library cannot be used in a constant declaration. Operators such as +, -, *, /, not, and, or, div, mod, ord, chr, sizeof, pi, int, trunc, round, frac, odd can be used, however. For more information on expressions, see chapter 8, page 250. Only constants of the following types can be declared: Ordinal types, Real types, Char, and String. The following are all valid constant declarations:
Const
e = 2.7182818; { Real type constant. } a = 2; { Ordinal (Integer) type constant. } c = '4'; { Character type constant. } s = 'This is a constant string'; {String type constant.} s = chr(32) ls = SizeOf(Longint); |
Assigning a value to an ordinary constant is not permitted. Thus, given the previous declaration, the following will result in a compiler error:
s := 'some other string';
|
Prior to version 1.9, Free Pascal did not correctly support 64-bit constants. As of version 1.9, 64-bits constants can be speci ed.