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
- Intrinsics/built-ins
- 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
Future (maybe?)
- 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
Happy C++mas!
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.
{ 6 } Comments
Where is the 64 bit choice in the IDE. I tried to copy the code
but when I compiled it did not like the __asm__ in the code.
the IDE is choosing the 32 bit compiler instead of the 64 bit compiler. I have C++ XE3 update 1.
Right mouse click on the Target Platform node in the Project Manager view - choose Add Platform, then select 64-Bit Windows target. The check box will also make this the active target node. then you can build 64-bit Windows apps. This is detailed in my blog post at http://blogs.embarcadero.com/davidi/2012/12/20/42150
Thank You. I see now. Should have looked at Dec 14 example first.
Looking at Dec 14, I see the size of the integer is 4 bytes. In the 64 bit compiler, I thought that the integer would be sized to 64 Bytes.
@Gary Olsen: Win64 keeps int at 4 bytes. It would be wrong for EMBT to arbitrarily go against platform norms.
Thanks, I need to read up more on 64 bit windows
Gary - yes Int stays at 4 bytes in C/C++ (all compilers even Microsoft) and Integer is 4 bytes in our Delphi 64-bit compiler as well
{ 1 } Trackback
[...] Migrating C++Builder Code to 64-bits - http://blogs.embarcadero.com/davidi/2012/12/21/42185 [...]
Post a Comment