Automatically output the callstack on a breakpoint in Visual Studio

When you’re dealing with a large program and multiple developers, it’s not always obvious how and when certain things get executed. One of the very useful ways to debug unexpected behaviour is to set a breakpoint on a suspect line of code, and examine the callstack when it gets hit to see the execution path.

For infrequent events, it’s not always desirable to halt the entire program while you do that though. Instead, you can tell Visual Studio to write the callstack to the output when the breakpoint gets hit, and immediately continue execution.

Read more Automatically output the callstack on a breakpoint in Visual Studio

Understanding C++11 move semantics

If you’re a programmer, you’ll be familiar with the difference between making a copy of an object, and making a reference (or a pointer) to it. If implemented correctly, the former duplicates the data, resulting in two (or more) independent instances. The latter allows the same original data to be accessed in two (or more) different ways. These concepts are common to many languages, and are essential to passing and returning data in your program.

As of C++11, you can think of ‘move’ as being a third alternative. It’s expanded the core features of the language, adding move constructors and move-assign operators to your class design arsenal. It’s required the introduction of a new type of reference as well, known as “R-value references”, which we’ll look at later.

To quote from Scott Meyers’ excellent C++11 training materials, “move is an optimization of copy”. In practical terms it’s very similar to copying, but can offer a number of advantages, especially where copying and referencing are impossible or undesirable. In this post, I’ll try to cover the basics of moves, so you can understand what they are and how you can start using them yourself.
Read more Understanding C++11 move semantics

Improve C++ performance in debug mode with inline expansion

When you’re dealing with an intensive real-time application, such as a game or simulation, a common problem is that debug builds in C++ can run much slower than release builds. This difference in run-time behaviour means it can be hard to reproduce and analyse bugs and other problems. There are several things you can do to improve it, and one which helped me recently was enabling inline expansion (or simply “inlining”).

A quick warning though: it won’t improve performance in all situations, and it can actually hinder debugging. For performance-critical code, you should first try manually optimising your algorithms.

Read more Improve C++ performance in debug mode with inline expansion

Introduction to Win32 Named Pipes (C++)

See also: Win32 named pipe example programs on GitHub.

There are times when it’s extremely useful to be able to pass some data between different programs running on the same system. For example, you might have multiple programs forming part of the same package, and they need to share some important information or work together to process something.

There are several ways to do it, but my choice in a recent task was to use the named pipes functionality of the Win32 API (working in C++). Note that pipes on other operating systems are a little different, so not all of this information is portable. Read more Introduction to Win32 Named Pipes (C++)

Running chapter headers in Microsoft Word

I’m in the process of writing up my doctoral thesis, and have had to wrestle with a lot of Word formatting. The biggest difficulty I had was separating the whole document into chapters. I wanted each chapter to start with a big heading like “Chapter 1 Introduction”, and to have that title repeated in the header of each subsequent page; i.e. running chapter headers throughout the document. It’s quite fiddly to do, but very useful once you’ve got it setup.
Read more Running chapter headers in Microsoft Word

FlashDevelop demo — Slider Puzzle

I’ve blogged before about using FlashDevelop to make Flash games for free. Just for fun, I decided to do a very little project tonight… a simple slider puzzle game to challenge myself. I set myself a time target of 3 hours to build the whole thing (assets included) from scratch. Ultimately, I ended up with 3 and a half hours, but I got it working. You can see the result below… Read more FlashDevelop demo — Slider Puzzle

avidscript lives!

As I’ve mentioned on some recent posts, I’ve been working on developing my own compiler and virtual machine lately. And finally, it lives! It’s taken 5 months, with some language revisions along the way, but I have set out what I intended to achieve… and that’s a custom programming language, compiled down to bytecode, running in a virtual machine. All of it was built myself from scratch in C++, using only a few of the standard libraries. Admittedly it’s not yet complete, and I’m sure there are many bugs… but for now, it’s working. 🙂
Read more avidscript lives!