Migrating from Delphi 5

Although compatibility between Delphi 5 and 6 is quite good, there are a few minor issues you should be aware of as you make the move.

Writable Typed Constants

The default state of the $J compiler switch (also known as $WRITEABLECONST) is now off, where it was on in previous versions. This means that attempts to assign to typed constants will raise a compiler error unless you explicitly enable this behavior using $J+.

Cardinal Unary Negation

Prior to Delphi 6, Delphi used 32-bit arithmetic to handle unary negation of Cardinal type numbers. This could lead to unexpected results. Consider the following bit of code:

var
   c: Cardinal;
   i: Int64;
begin
   c := 4294967294;
   i := -c;
   WriteLn(i);
end;

In Delphi 5, the value of i

Get Borland® Delphi™ 6 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.