-
Memory allocators in C++ - Part 1
Sep 09, 2020
When you want to instantiate a class or a struct in the dynamic memory space, we normally use the new and delete operators. …
-
Minimal implementations in Modern C++: Producer-Consumer problem
Apr 20, 2020
This implementation was inspired by Stackoverflow user Yakk - Adam Nevraumont ’s answer for a question about std::condition_variable . I extended it to make it a working example, and I plan to use it as a base for a new project I have in mind. …
-
Make your pointers smart - C++ good practices
Feb 28, 2018
Ever since the C++ language was first standardized, new and delete were defined as the methods to create/delete objects dynamically. The new operator allocates a memory block to construct an object and then calls the proper class' constructor to initialize it. If successful, this operator will return a pointer to the location of the memory block. Otherwise, it will return nullptr or it will throw an exception. The delete operator executes the inverse operation, it deallocates object’s memory block.…
-
Analyze the testing coverage of your C++ code
Nov 18, 2017
Writing unit tests is a great way to ensure that your code is behaving correctly. But how can you tell how much of your code are you testing? The GCC compiler provides tools to analyze the testing coverage of your project. In this post, I will show you how to integrate these tools in a CMake project. …
-
Test your C++ code with the Google Test framework
Oct 31, 2017
In a previous post , I showed you a C/C++ template that you can use for a project. I felt that it needed a basic testing framework. Therefore, we are going to learn how to install and use the Google Test framework to write tests. When we have finished this tutorial, we will have an executable that will run tests for our code. …
-
First Steps With Go
Sep 10, 2017
Go is a simple and powerful programming language. Its syntax is familiar to C/C++ but it definately has improvements in comparison. It has a bunch of great features such as static types, memory safety, garbage collection, and it is targeted to concurrent programming. I discovered it very recently, so I want to start simple and learn the basics of this language. In this post, we will write our first Go program and library. Also, we will learn how to unit tests our Go programs. …
-
Source-to-source compilation with Lex-Yacc
Jul 15, 2017
In this post, I will describe a source-to-source compiler that transforms a Brainfuck program into its equivalent 64 bits assembly code. The assembly program can be built into a executable, thus allowing you to run Brainfuck programs natively. …
-
Building a basic C/C++ project template
Apr 17, 2017
Starting a C/C++ project can be as easy or as difficult as you want. Personally, I don’t like to fire up an IDE just for a small program. So, I end up using a text editor and compiling by terminal. However, the compilation process can get tedious. In this post, we will build a simple project template for a C/C++ program. This project will use the CMake tool to handle all the compilation process. …