Posts

  • Classifying Characters with Simple Functions

    This is the second in a series of articles I’m writing on character classification as used in lexers and compilers. In this I describe the simplest method of character classification which is using plain functions with the logic directly inside.

  • Investigations into Classifying Characters

    For an application that I’m building I am developing a compiler, and the first part of that is writing a Lexer to convert characters into tokens. A fundamental part of this is to classify characters (ASCII, UTF-8, etc) into character classes in an efficient manner so that they can be lexed appropriately. Doing some research and thinking about this provided me with three methods of classifying characters, but this made me curious and I had questions I wanted the answers to.

  • C++ Anti-Patterns: Calling reserve in a loop

    This C++ anti-pattern is found in code where the programmer wanted to do the right thing for performance reasons, but for one reason or another it didn’t end up that way. That is when there’s a call to reserve inside of a loop. This may be the result of a refactor where a loop was added surrounding existing code, or just written with the best intentions.

  • Enhancements to the Blob Classes

    This is a short post to describe an update that I made to the Blob classes from the previous article.

  • Ever Useful Blob Classes

    In this article I describe (and make available) a set of simple but useful classes for use in file and other IO. I don’t claim that these are completely original or unique, but I have found them useful in various circumstances and therefore want to share them with others.

  • Configuring Vcpkg with a Custom Triplet

    In this article I extend the existing Visual Studio CMake project with vcpkg to be able to customise packages that we use in vcpkg. The main reasons to do this is to select alternative configurations of packages like spdlog, or to switch the linking method for a particular package, for example linking dynamically with LGPL libraries but statically with everything else.

  • Making a flexible assert in C++

    In this article I tell the tale of development of a flexible assert macro for my base/common/core C++ library which I use in a number of projects.

  • Thoughts on Ignorable (or Skippable) Assertions

    For those that are unfamiliar, an ignorable or skippable assert is like a normal assert - which halts the program and displays an error dialog to the user if a checks fails - with the added option of being able to ignore or skip the assert instead, and continue execution of the program.

    These are my thoughts about so called ignorable or skippable assertions in code, most often found in game development. In short I believe that they are a terrible idea, where there is minimal (if any) short term benefit compared to many problems that will develop and only become apparent in the long term.

  • Three ways to setup Vcpkg in a CMake project for Visual Studio 2022

    In this article I present three different ways of integrating and using the vcpkg package manager with a CMake project. Each of these ways is something I’ve used before in my own projects, and each is useful in its own way with its own benefits and drawbacks. This article builds on the previous CMake Visual Studio project article and it uses that setup in the examples here.

  • Fixing CMake projects for debuggable releases on Windows

    This short article provides a few snippets that work to clean up the default CMake build configurations and make them more useful to developing and releasing software on Windows. Namely making sure that debugging symbols are available in the Release configuration, and removing two of the configurations that don’t make much sense.

  • Undoing Windows Header macro damage

    Here is a simple header file (Github link) which I use in my own projects instead of including <windows.h> directly. It sets some simple flags, includes <windows.h>, and then goes and undefines as many character encoding related Windows API macros as possible. This has the effect of removing all of the macros which select either the A or W set of Windows API functions, and I do this for two reasons.

  • Setting up a basic Windows C++ project with CMake for Visual Studio 2022

    This is the first article in a series which describes how to configure a C++ project using CMake for development in Visual Studio in a way that I use in my own projects. Initially I had intended to write this in a single article but it grew and grew so I am splitting it into smaller more self contained articles where I can use a few more words to explain the reasoning behind these decisions. In this article I will describe the basic layout and configuration of the project, and in later articles I will build on this core, integrating the vcpkg package manager, adding testing with Google Test, and more.

  • Custom Precompiled Headers in CMake for Visual Studio

    This is a short snippet on how to implement custom precompiled headers in CMake for Visual Studio. I know that CMake has its own way of specifying includes for automatically generating precompiled header files but this option allows for more control and flexibility allowing you to add in defines and forward declarations, and doesn’t require rebuilding CMake for every precompiled header change.

  • Lessons Learnt: Know when to bend or break user requirements

    I know that some of these lessons might be very simple or appear to be common sense to some readers here, but ever experienced software developer was once a junior like I was in this story. I also believe that there should be no shame in asking what would appear to be simple or stupid questions, or in sharing stories from long ago.

    This lesson is all about learning to evaluate software requirements that you get from the customer and figuring how to bend or break them in order to efficiently apply them to the target hardware.

  • C++ Anti-Patterns: Passing a result variable in by reference badly

    This C++ anti-pattern might be a bit controversial to some people, as it’s a common design holdover from the early days of game development and from C or early C++ code. The pattern is to pass a container into a function by reference (or pointer) and use that to return the result from the function. While in general this is not strictly an anti-pattern, this particular example shown below does deserve that title, and I’ve seen it written frequently in code, even by experienced senior people.

    void FooHolder::GetFooElements( vector<Foo>& out )
    {
    	out.reserve( m_elements.size() );
    	for ( const auto& foo : m_elements )
    	{
    		out.push_back( foo );
    	}
    }
    
  • Obligatory First Post

    Hi everyone,

    This is the obligatory first post that needs to be at the start of every blog. I’m hoping it will be one of many where I describe various technical concepts that I have learnt, show off various projects in both software and hardware that I have worked on, and talk about some technical opinions of mine.

    Time will tell though.

subscribe via RSS