Embarcadero RAD Studio 11 is Now Available!

Embarcadero have now officially released the latest version of their IDE: RAD Studio 11 Alexandria promises a great new high DPI experience.

You can start a free trial download at https://www.embarcadero.com/products/rad-studio

I will be mentioning some of the benefits of upgrading for C++ users in the coming weeks.

RAD Studio 11 is Coming!

Embarcadero have announced that RAD Studio 11 is coming. Looking at the beta referred to in the link below it is clear that there are some good things to be expected in this new release.


Free Learn To Code Week – Great for Students

If you want a chance to learn to code (or maybe pick up ideas about how to teach coding?) maybe this “Embarcadero Coding Summer Camp” which officially started yesterday is for you…..


Tips For Using GoogleTests with Embarcadero Clang64 for Windows VCL Projects.

In my previous posting I covered how to install GoogleTests framework ready for use with Embarcadero C++. Now I am going to offer some advice on how to write simple tests for your own VCL projects using the GoogleTests framework framework. I will assume Clang64 but it all applies equally to Clang32 projects.

If you try to use the GoogleTests files where they were installed you end up with very long include paths and you also lose your project independance. It seems much more convenient to create a copy of the key files in a directory local to your project. I suugest:

  1. Create a directory in your project called “GoogleTest”
  2. Inside “GoogleTest create a directory “LibWin64”
  3. Inside “LibWin64” copy the four files gmock.a, gmock_main.a, gtest.a and gtest_main.a (only gtest.a is actually required to run simple tests) from the lib folder C:\Users\ [ your account name ] \Documents\Embarcadero\Studio\21.0\CatalogRepository\GoogleTest-2021.03\cbuilder\lib\Win64\Release.
  4. Inside “GoogleTest create a directory “Include”
  5. Inside “Include” copy the directory “gtest” from C:\Users\ [ your account name ] \Documents\Embarcadero\Studio\21.0\CatalogRepository\GoogleTest-2021.03\googletest\include\gtest, making sure you include the “Internal” folder and all it’s contents (including further sub-directories).
  6. In your project group create a new windows64 bit VCL console application. As well as the files you want to test and the files containing the testing code you need to add to the project the library file …GoogleTest\LibWin64.
  7. In your project options add the include path ….GoogleTest\Include\gtest.

Having configured your project in this way you then need to add the line “#include “gtest.h” at the begining of each of your *.cpp files that you generate to test your project (convention suggests one test file for each *.cpp unit in your main project). In addition, in your main VCL console cpp file, you need to change the “main()” program entry point so that it becomes:

int _tmain(int argc, _TCHAR* argv[])
  printf("Running main() from %s\n", __FILE__);
  ::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();

One key point to be aware of is that you must build your test project (you still choose which ever setting you want for projects you ship) using dynamic run time linking of packages set to true. Set this in project | options | C++ Linker.

Using GoogleTests with Embarcadero Clang64 for Windows VCL Projects

The old C++ Builder “classic” win32 compiler worked well with the associated DUnit framework for unit testing.

With the clang compilers (both clang32 and clang64) there are issues when using the DUnit framework. It makes sense to use a framework that is up to date and receiving on going support. Such a framework is GoogleTests.

There are two stages to using GoogleTests with your own Windows clang64 C++ project.

Firstly you have to download it, install it and confirm that all is well. After doing that you have to work out how to use it with your own project.

Downloading is easy if you have C++ Builder 10.4.2 as GoogleTests appears in the Getit package manager. Using Getit the test framework along with sample programs can be automatically downloaded and installed.

The resultant files are stored in

C:\Users\[your account name here] \Documents\Embarcadero\Studio\21.0\CatalogRepository\GoogleTest-2021.03

We will call this long path ”…GT2021.03” for the rest of this blog.

Now build and run the files as follows.

Using the C++ Builder IDE, open the project group GoogleTest.groupproj in …GT2021.03\cbuilder
You can now build all the projects (they are set for clang32). But for our discussion we need it to run with clang64. Edit each of the project settings for each of the projects in the project group so that each project uses clang64.

Now do a build all projects to build everything using clang64.

The exe file resulting from the sample8_unittest.cbproj is file sample8_unittest.exe in directory …GT2021.03\cbuilder\bin\Win64\Release

Open a DOS command line shell in this directory and then run sample8_unittest.exe. You will see that it reports 12 test passes.

Great ! You’ve got GoogleTests installed and looking good! In my next blog I will make some suggestions about how to use it with your C++ Builder VCL clang64 project.

More on Order of Events When Creating and Destroying a Form in C++ Builder

The last two blogs have been about Embarcadero C++ Builder events that are fired when a form is created or destroyed.

As an addition to these postings I refer everyone to Remy’s stack overflow comments about the order of events and the fact that it’s good to put constructor stuff in the constructor


(Scroll down to the end of the long list of comments posted on this stack overflow question)

As well as pointing out that in the past (early versions of C++ Builder) there may have been an issue with the event firing order Remy wisely advises that it is always good C++ programming practice to put initialisation code in the constructor. Similarly it’s always advisable to put any close down tidying up code in the destructor.

I completely endorse Remy’s wise words.

Order of Events When Destroying a Form in C++ Builder

Following on from my previous blog it may be useful to know the order of events when a form is destroyed.

So, using C++ Builder 10.4.2 with a VCL project and the “classic compiler” here’s the sequence that the events get called when destroying the form…..


Order of Events When Creating a Form in C++ Builder

There are times when it is important to be aware of the order of events that are fired when a form is created. I’ve found this particularly useful when dealing with the main form.

So, using C++ Builder 10.4.2 with a VCL project and the “classic compiler” here’s the sequence that the events get called when creating the form…..


Make your Source Code more Readable When Passing a Boolean.

Suppose you have a C++ function declared as follows:

void UpdateDisplay(bool WithDelay);

and somewhere later you want to use this, calling it without the delay.

You could write:


But a simple way to make your source code more readable (and hence more maintainable by yourself and your team in the future) is to write:

const bool WithDelay{false};

When you compile this code for release the local variable “WithDelay” will be optimised away so this improvement to source code readability incurs no performance cost penalty.