Category Archives: C & C++

Optimization by puzzle

Given a query routine that takes a name and may return several, write a routine that takes a single name and returns a set of names for which each of the following is true: For each name in the set, … Continue reading

Posted in Algorithms, C & C++, C++ for the self-taught, Software Design, Software Development, Software Engineering | 1 Comment

Optimizing with type lists

In this post, I will take a brief look at how using type lists can help optimize certain applications.

Posted in C & C++ | Comments Off

A functional version of the KMP algorithm

For one of the projects I’m working on, I needed a compile-time version of the KMP algorithm in C++. I started by making the algorithm functional.

Posted in C & C++, Software Development | Comments Off

Run-time composed predicates and Code generation

While working on Arachnida, preparing version 2.2 due out this fall, one of the things we’ll be introducing is a hardened OpenSSL transport-layer-security plug-in, to replace the one we’ve had for the last seven or so years. One of the … Continue reading

Posted in C & C++, C++ for the self-taught, Software Design | Comments Off

Sometimes, your right hand should know what your left hand is doing

Especially if you’re a compiler…

Posted in C & C++, Software Development | Comments Off

Conditional in-place merge algorithm

Say you have a sorted sequence of objects. Go ahead, say: “I have a sorted sequence of objects!” Now say it’s fairly cheap to copy those objects, you need to be space-efficient and your sequence may have partial duplicates — … Continue reading

Posted in C & C++ | Tagged | Comments Off

Structure alignment and padding

In my previous post on the subject, I talked about using magic numbers and versions, alignment, and later added a note about endianness after a suggestion from Michel Fortin. This time, I’ll talk about padding, how the sizeof operator can … Continue reading

Posted in C & C++, Embedded software development, Software Development | Comments Off

Minor changes in style

I am not usually one to make much of a fuss about coding style: as long as the code is easily readable, I don’t much care whether you use tabs or spaces to indent, how you align your curly quotes, … Continue reading

Posted in C & C++, Software Development | Comments Off

What happens if structures aren’t well-designed

In my previous post, I explained how to design a structure for persisting and communicating. I didn’t say why I explained it — just that things get frustrating if these simple rules aren’t followed. In this post, I will tell … Continue reading

Posted in C & C++, C++ for the self-taught, Embedded software development, Software Design | Comments Off

How to design a struct for storage or communicating

One of the most common ways of “persisting” or communicating data in an embedded device is to just dump it into persistent storage or onto the wire: rather than generating XML, JSON or some other format which would later have … Continue reading

Posted in C & C++, C++ for the self-taught, Embedded software development, Software Design | 5 Comments