Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++How-To'sModernizationNewsRAD StudioWindows

Upgrading C++Builder 12.2: Tip #4 1/2: Check out compiler safety options

Screenshot Radically Different Why C++Builder 122 Matters webinarWelcome 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 1/2: Check out compiler safety options

Did tip 4 worry you? It shouldn’t, because it was really a tool to improve your code. But here’s a tip that’s the other way around: compiler settings to use to make your code safer.

  • Did you know that some null pointer checks can be optimised out, if the compiler thinks you’ve already dereferenced it?
    -fno-delete-null-pointer-checks
  • Did you know that there’s a warning to detect when a switch case falls through?
    -Wimplicit-fallthrough
    The classic compiler never told you about that!
  • Did you know there are multiple switches to check format statements (eg printf) usage?

You can find all these on these two fantastic resources:

  1. Compiler Options Hardening Guide for C and C++
    by the Open Source Security Foundation (OpenSSF) Best Practices Working Group
  2. Leveraging Your Toolchain to Improve Security
    by Phillip Johnston

Both these cover multiple compilers and standard libraries. Check for the flags that apply to Clang, version <= 15, and to libc++ version <= 15, which is LLVM’s STL and the one we use. (Flags for versions 16-18 are not yet applicable but will be in future.) There are some great flags there that will make your code better — and that you can use with the new C++Builder 12.2 and it’s Windows 64-bit Modern C++ toolchain.

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

David is an Australian developer, currently living in far-north Europe. He is the senior product manager for C++ at Idera, looking after C++Builder and Visual Assist.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES