cmake is not great, but it doesn’t matter

cmake, the language is not great. It is just not a pleasant tool to work with. Not at all; it feels like it was not designed as a language, but a mere configuration file that sets build options in a compiler-agnostic way. But, it hits many important bullet points for building software and most importantly: "just works". As a result, it has gained popularity over the years because cmake, the software is quite good. As it happens often, control structures

Murmur3 hash as a constexpr function

C++14 relaxed many restrictions on constexpr functions. The ability to contain branching, loops, switch statements makes them really easy to use. Implementing complicated functions at compile time is now a piece of cake. To prove this point, I tried and implemented Murmur3A, the Murmur3 hash variant which is optimized for x86 ((Not that this matters for constexpr; the point is, it computes the same values as that version of the algorithm does)) and comp

Turning a legacy MFC DLL project into EXE

Recently I had to convert a MFC DLL project to EXE. At first, this appears to be an easy task, since MFC abstracts the entry point of the application, right? The answer, as always with MFC is an awkward "yeeeaah.... but". In this post I'm detailing all the steps that need to be taken to successfully convert your DLL into a EXE project, possibly saving some hairpulling if you need to do the same. During this project I used Microsoft Visual Studio 2010, b...

Emulating the static initialization blocks of Java in C++

What is a static initialization block? In Java, there is a language construct called a static initialization block. The static initialization block will be called the first time the class is loaded by the Java runtime. For example, consider the following code snippet ((The highlighting in this code snippet is different because highlight.js had problems with this rarely used construct. As a workaround, I used a GitHub Gist for displaying this snippet.)):

Rarely known C++ constructs (part 1): Function try blocks

C++ has some language constructs that are rarely seen in use. These constructs have their own, valid uses, but should be used sparingly. As the now adage-status quote from The Old New Thing says: Code is read much more often than it is written, so plan accordingly In this series we will take a look at different instances of unusual C++ language constructs, shortly explaining their use-cases, syntax and pitfalls. UPDATE: the series was moved to Dr.

Implementing a code generator with libclang

[DOI: 10.5708/szelei.2014.A.1] Introduction Click here to skip the introduction and see the code. The following article covers the process of implementing a practical code generator for C++ in detail. You can find the full source code for the article on GitHub. A code generator is a very useful asset in a larger C++ project. Due to the lack of introspection in the language, implementing the likes of reflection, script binding and serialization re