Pure virtual (abstract) final functions in C++

Today I ran across an interesting little quirk of C++11. You can declare a member function which is pure virtual, has no implementation, and which is final. That means the class can never be instantiated or inherited, and the function will never have a body.

For example:

class Widget
{
    virtual void foo() final = 0;
};

Read more Pure virtual (abstract) final functions in C++

Order of parameter evaluation in C++

The low-level details of how data gets passed into a function are often overlooked by programmers. We obviously care about passing by value vs. reference, and perhaps also by copy vs. move, but it’s easy to ignore anything deeper than that.

With C++ in particular, this can cause an unexpected problem regarding the order in which things actually happen. In this post, we’ll look at what can go wrong, and how to deal with it.
Read more Order of parameter evaluation in C++

MFC prevents bad_alloc from being thrown

According to the C++ standard, the new operator should throw std::bad_alloc if it fails. This will typically happen if your process has run out of memory. However, this isn’t the case if your program uses the (rather outdated) Microsoft Foundation Classes. In this post, we’ll look at what’s going on, and what you can do about it.
Read more MFC prevents bad_alloc from being thrown

Make uPlay work better

I usually buy PC games through Steam, but occasionally I end up getting a game which requires Ubisoft’s uPlay to run. This can include franchises such as Far Cry, Assassin’s Creed, and Splinter Cell. Unfortunately, uPlay has some major issues causing it to crash regularly, making it impossible to play some games. I’ve got a few quick tips here which seem to solve the issues for me. Read more Make uPlay work better

Convert a number to a binary string (and back) in C++

Sometimes it’s useful to output the binary representation of a number in text, i.e. as an ASCII string of 0’s and 1’s. There are also situations where you might want convert back the other way, e.g. if you want to let a user enter a binary string manually. The bitset class in C++ makes this surprisingly quick and easy.
Read more Convert a number to a binary string (and back) in C++

Prevent Word from putting page breaks in table rows

If you’re using large tables in Word, you may sometimes find that they run across more than one page. Quite often, the page break occurs inside a row, which means the row gets split across two pages. To the person reading it, this can potentially make it look like two separate rows, which is frustrating.

The usual “Keep lines together” paragraph options don’t prevent this. You need to set the table properties instead.
Read more Prevent Word from putting page breaks in table rows

Changing the emulation mode of the Microsoft Web Browser ActiveX control

I’ve been working on an MFC project which embeds a basic web-browser component in a dialog, in the form of a Microsoft Web Browser ActiveX component. (I know… these are ancient technologies… but sometimes you’ve got to work with what’s available on a project!)

Technically, the control hooks into whatever version of Internet Explorer (IE) you’re running on the system. However, it always seemed to fall-back on IE7 emulation mode for us, meaning a lot of our modern standards-compliant HTML wouldn’t work properly. Thankfully, there is a way to fix this problem, although it’s far from obvious!

Read more Changing the emulation mode of the Microsoft Web Browser ActiveX control

New Arduino Q&A site online

If you’re interested in using Arduinos then I recommend checking-out the new Arduino Q&A site over on Stack Exchange. (It’s totally free to use.)

As with most Stack Exchange sites, it was in private beta for a couple of weeks to get it started. It’s now gone into public beta, which means it’s fully functional and anybody can join in. It’s a great place to go if you need help with specific Arduino problems, or if you’ve got some awesome expertise that you want to share.

NSIS Access Control problem with built-in users group

I was dealing with a subtle issue recently involving setting access permissions using NSIS (Nullsoft Scriptable Install System). In the end, it turned out that the problem was not with NSIS at all. Rather, it was a misunderstanding on our part regarding an unexpected quirk in Windows. However, hopefully this post will help anybody who encounters a similar issue.

Our installer was supposed to enable read/write permissions for all users on certain important files and registry keys. However, some users were finding these files/keys were not accessible, and it was preventing the software from working correctly.

Read more NSIS Access Control problem with built-in users group

What is a serial-to-parallel shift register?

A serial-to-parallel shift register (or SIPO: Serial In Parallel Out) lets you take a sequence of signals on one output, and split them up into several separate outputs. For example, if you don’t have enough GPIO pins on your Raspberry Pi, Arduino, or other computer/microcontroller, you can use a shift register to add more.

In this post, I’ll be looking at the 74HC595, which is an 8-bit SIPO IC (i.e. it gives you 8 outputs). The advantage of this chip over some dedicated port expanders is that it doesn’t require a complex protocol like I2C or SPI, and it doesn’t need a particular clock speed. That means you can control it with pretty much any digital output channels, and it’s very easy to write simple software to communicate with it.
Read more What is a serial-to-parallel shift register?