Note: This is all pre-release information, which I’ve been given permission to share. It’s all subject to change without notice until Delphi XE2 actually ships, and while I’ve been given permission to share this information with you, this is not an official statement from Embarcadero and should not be considered binding in any way.
There’s so much exciting stuff in Delphi XE2, it’s hard to keep track of it all. By now everyone has heard that it’s got a cross-compiler for Mac OS X, and that with the FireMonkey framework, you can write applications that can be compiled for Windows, OS X, and even iOS. In all the excitement over FireMonkey and Mac/iPhone support, I think one really big new item hasn’t gotten as much attention as it should: the 64-bit Windows Compiler.
The 64-bit compiler has been a long-awaited Delphi feature, and it’s finally here. It’s implemented as a separate compiler from the 32-bit compiler. The command line compiler is a distinct executable from the 32-bit command line compiler (as opposed to just being a compiler switch to turn on 64-bit).
In Delphi XE2, each project has one or more “Target Platforms.” These platforms could be 32-bit Windows, 64-bit Windows, OS X, or iOS, depending on the framework being used. 64-bit Windows is available both with the new FireMonkey framework and with the venerable VCL. That means that in order to turn a 32-bit Windows application from Delphi XE (or earlier) into a 64-bit application, all you have to do is add the 64-bit Windows platform to the project. It’s really that simple.
There are, of course, a couple of things that may cause some trouble when migrating a 32-bit application to 64-bit:
- Windows API calls must be 64-bit versions (the VCL and RTL do this for you, but if you’re writing direct API code yourself, you’ll want to make sure you’re calling 64-bit functions).
- You can use inline assembler, but you can’t mix assembler and Pascal code in the same block.
- In the 64-bit environment, all pointers are 8 bytes, whereas in Win32, pointers are 4 bytes. This means any code that assumes that a pointer is 4 bytes will need to be rethought (a little more on this below).
- Some other data types (such as Extended, procedure of object, and typed file blocks) are different sizes. Just stop assuming anything other than sizeof(SomeType) as the size of a particular type, and you’ll be in good shape.
- All of the integer types except NativeInt are the same size in 64-bit and 32-bit. Integer is still 4 bytes, In64 is still 8 bytes, etc…. NativeInt is the only integer type that changes: A 32-bit NativeInt is 4 bytes, and a 64-bit NativeInt is 8 bytes.
- Single, Double, Real48, Comp, and Currency floating point types are all the same as in 32-bit. There’s a new Extended80 type that is the same size in both environments (10 bytes, the same size as Extended in the 32-bit environment).
- The MaxInt and MaxLongInt constants remain the same, at 0x7FFFFFFF.
Another important thing to understand is that the Delphi IDE itself is still a 32-bit Windows application. This may have some impact on the way you write 64-bit code:
- Design time packages need to be 32-bit. This means that any components, packages, or libraries that will need to be loaded into the IDE must have 32-bit versions.
Now, let’s talk about the debugger: In a nutshell, it works. If you’re running on a 64-bit machine, the [32-bit] IDE will happily debug your 64-bit application. Breakpoints work, watches and evaluations work, even the CPU window works:
If you’re not using a 64-bit machine, but are writing a 64-bit application using a 32-bit machine (why are you doing that?), the debugger will still work remotely. Using the included “Platform Assistant” running on a 64-bit machine, you can run the IDE on a 32-bit machine and remotely run and debug the 64-bit application (this, incidentally, is the same mechanism by which OS X debugging works).
A final thought: The Delphi community has been clamoring for a 64-bit compiler for years, and Embarcadero has really delivered. 64-bit Delphi is available with both VCL and FireMonkey. Changes to existing code are minimal. The debugger is top-notch and the IDE integration is amazing. Personally, I think Embarcadero has gotten 64-bit Delphi right in a very big way.
Want to see more RAD Studio XE2? Check out the RAD Studio World Tour in a city near you.
Delphi XE2 looks awesome. Make it (and whatever version you’re using now) even more awesome with Castalia For Delphi, my collection of IDE enhancements that will change the way read and write code forever.