Welcome to a series of tips and tricks for taking advantage of the new Windows 64-bit Modern toolchain in C++Builder / RAD Studio 12.2! This builds on a webinar we did sharing a bunch of useful information on why and how the new C++Builder matters to you, where this was the very end (so go watch the start!)
Tip #4 ¾: Help When Moving from 32 to 64 Bit
Tip 4 was about the compiler communicating to you about potentially unsafe or incorrect code; tip 4 ½ was on compiler settings to improve code safety; and this tip rounds out this very long tip #4 with more on compiler flags and warnings… now, ones that help you move from 32 to 64 bit code.
The new Windows 64-bit Modern toolchain is really good, and not everyone is on 64-bit yet. So you might want to migrate to it from old Clang 32, or from old classic. In effect, that’s two migrations at once: 32 -> 64, as well as one compiler -> another.
We’ve done our best to make sure it’s highly compatible, and very capable, addressing the second. But if you want to move to it, and that requires both those steps at once, go for it. It’s very likely the main thing to work on will be ensuring your 32-bit code works when compiled as 64-bit, and the majority of issues there are things like truncating pointers, casting types to narrower than they might really hold, mistakes in pointer arithmetic, etc.
-Wpointer-sign
-Wpointer-to-int-cast
-Wpointer-type-mismatch
-Wsizeof-pointer-memaccess
-Wvoid-pointer-to-int-cast
…and many more.
The compiler has a wide variety of warnings that catch exactly these (far more than just size truncation), and so you can turn those on in order to catch 32 -> 64bit migration issues. You can find them by reading through this diagnostics reference (try searching for ‘pointer’) but by far the easiest way is simply to run with -Wall (all warnings) or -Wextra (even more than all, though be more careful here in that some may be false positives.)
The compiler communicates to you, and the compiler helps you. If you’re porting code, turn warnings on, and fix them. It really helps.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition