In my first blog post about Bruneau Babet’s CodeRage 7 C++ session, "Migrating C++Builder Code to 64-bits", I covered some of the language extensions added to support Win64 and integration with Delphi language features. In part two I’ll list a few more of the migration items that Bruneau presented. With C++Builder XE3 64-bit, you can generally take your C++ 32-but VCL and FireMonkey applications, add the 64-bit Windows target platform and do a rebuild. But, since the 64-bit compiler is based on a different compiler (and just like with Delphi 64-bit migration), there will always be some Win64 adn 64-bit considerations that you need to take a look at. Many of these items are also documented on the Embarcadero DocWiki at http://docwiki.embarcadero.com/RADStudio/XE3/en/C%2B%2BBuilder_64-bit_Windows_Application_Development, http://docwiki.embarcadero.com/RADStudio/XE3/en/What%27s_New_in_C%2B%2BBuilder_64-Bit_Windows and http://docwiki.embarcadero.com/RADStudio/XE3/en/BCC64.EXE,_the_C%2B%2B_64-bit_Windows_Compiler.
Linking libraries and objects
If you have separately compiled object and library files, you’ll need to be aware of the differences in file extensions. In using the "#pragma link" and "#pragma comment", Bruneau gave the following advice:
- #pragma link “<obj-name>” - Remove extension: WIN32 will default to .obj and WIN64 to .o
- #pragma comment(lib, “<lib-name>”) - Remove extension: WIN32 will default to .lib and WIN64 to .a
Differences in IDE generated event handlers
Watch for differences between WIN32 and WIN64 in IDE-generated event handlers. E.g. TPoint and other records 5-8 bytes long fit in a register in WIN64 but are passed by reference in WIN32.
Cool in C++ 64-bit compiler
- C++11 is stricter/safer
- New compiler has lots of extensions
- Binary constants (e.g. 0b1100101)
- printf format specifier validation
- Correct template handling/destructor/etc
- More descriptive error/warning messages
Not so cool in C++ 64-bit compiler
- No Unicode identifier support
- No preprocessor sizeof(<type>) - Use static_assert
- Pre-compiled header (PCH) handling - a very manual process (no wizard like in C++ 32-bit)
- No CodeGuard for C++64
- Inline assembly is different, uses the AT&T/GCC format (see my blog post - http://blogs.embarcadero.com/davidi/2012/12/21/42152)
- Objects not consumable by Delphi 64-bit compiler
- Strong typeinfo - TFilename properties and Object Inspector
- Refactoring - Clang libtooling (http://clang.llvm.org/docs/LibTooling.html)
Watch/Download the C++Builder 64-bit Compiler Preview Video
Additional details about the 64-bit C++Builder compiler are available in the preview video. Watch the C++ 64-bit compiler preview video on YouTube at http://www.youtube.com/watch?v=PwwMpBUoR6Y. You can also download the MP4 video file at http://cc.embarcadero.com/item/29197. The preview video is 9 minutes long.
Try the C++Builder 64-bit compiler
The C++Builder XE3 and RAD Studio XE3 free trial downloads have been updated to include the new C++Builder 64-bit compiler. Trial downloads are available at https://downloads.embarcadero.com/free/c_builder
During the first 25 days of December leading up to Christmas, I will blog about the release of the C++Builder 64-bit compiler for Microsoft Windows and C++Builder XE3 support for building VCL and FireMonkey 2 applications.