# Path error when building with Conan and CMake

I recently encountered a mysterious path error when attempting to build a C++ project on Windows using Conan and CMake. The main error message wasn’t particularly helpful though:

 ERROR: conanfile.py (my-project/1.0@None/None): Error in build() method, line 71
cmake.configure(source_folder=".")
ConanException: Error 1 while executing cd C:\path\to\repo\build && cmake -G "Visual Studio 15 2017 Win64" ...
20190718 15:00:46 : ERROR : Problem: conan_build: 1
20190718 15:00:46 : ERROR : Exit: 1

I’ve edited the message for brevity and to avoid sharing details of exactly which project it was. The main point is that Conan encountered the error when it was trying to run a shell command. The shell command was attempting to enter a build directory and invoke CMake. I tried to run the command manually and it worked correctly so something strange was going on behind the scenes.

Read more Path error when building with Conan and CMake

# Workaround for nvcc pthread issue

I recently upgraded various pieces of software on my work PC. Afterwards, I found that our C++/CUDA projects wouldn’t build. The following error was reported:

nvcc fatal   : Unknown option 'pthread'

I was attempting to build it in CLion 2018.2.5 using the bundled CMake 3.12.2. My OS is Ubuntu 18.04 and I’m using CUDA 9.1.

So far, I haven’t been able to find a proper solution. However, I have found a simple workaround. If you know of a better solution then please let me know in the comments!

# Importing email folders into Gmail

Google has some useful documentation about importing emails into Gmail via POP. However, the instructions don’t work very well if the messages in your old account are organised into folders. You will only end up importing messages which are directly in your inbox. I have found a few solutions though which I will outline in this post.

# Comfort Curve Keyboard 3000 bug on Windows 10

I’ve been using the Microsoft Comfort Curve Keyboard 3000 for a number of years, and it’s mostly served me very well. However, since upgrading to Windows 10, the keyboard has shown an annoying bug. If I leave it for a few seconds without pressing anything then the keyboard seems to shut down. If any keys are held down at that point then the OS doesn’t notice when they get released. The result is it thinks the keys are still held until I pressed and release them again. Sami Korhonen has made a YouTube video demonstrating the same problem.

# Why Python 3 doesn’t write the Unicode BOM

I’ve been using Python scripts to automatically edit and output Windows Resource files (*.rc) for C++ projects in Visual Studio 2013. When handling Unicode, Windows and Visual Studio always want little endian UTF-16 encoding, and the resource file should always start with the Unicode BOM (Byte Order Mark). However, despite the promises in the documentation, I found that Python wasn’t outputting the BOM automatically.

I nearly resorted to outputting it manually, but as is often the case with Python, the correct approach is simpler than it seems. Read more Why Python 3 doesn’t write the Unicode BOM

# Output file encoding in Python 3

Unicode is becoming very widespread now (for good reason), and one of the great benefits of Python 3.x is that it handles Unicode natively. There are different ways to represent Unicode though, so how do you set the file encoding in Python when you’re writing out to file?

It’s not immediately obvious from some of the official documentation, but thankfully it’s not complicated. I’ll give a quick overview in this post. Read more Output file encoding in Python 3

# Generate UTF-8 dictionaries using gettext

I’ve been setting up localisation for an application using a combination of tools: the Boost Locale library, and the widely used gettext tools. I’m wanting to work entirely in UTF-8 because it should be suitable for pretty much any language we’re likely to need, and it should hopefully avoid problems of mixing encodings. However, I found that the tools kept falling-back to outdated character sets instead.

Fortunately, there’s a fairly easy solution which I’ll outline quickly in this post. Read more Generate UTF-8 dictionaries using gettext

# Decimal places in a floating point number

Floating point numbers are a mainstay of programming in areas such as games, graphics, and simulation. On the whole, they are easy and intuitive to use. However, they have certain quirks and issues to be aware of. For example, their representation is inherently flexible and often approximate. This means there’s no definitive answer to the question of how many decimal places they can hold.

By looking at the way floating point numbers are stored, it’s possible to understand why this happens, and what precision is likely to be available. Hypothetically, it’s possible under certain circumstances to get up to about 45 decimal places in a C++ float, and 324 in a double. However, as we’ll see in this post, it depends on context.
Read more Decimal places in a floating point number

# Emit audible warning from a batch script

Windows Batch (*.bat) scripting is archaic and painful, but occasionally useful for quick bits of environment setup. It’s not always obvious to the user when something has gone wrong though as it’s easy to lose the information amidst other text which scrolls by. An audible warning can be a useful alternative to draw attention to a problem.
Read more Emit audible warning from a batch script

# How to check that a function is constexpr

I’ve been implementing quite a few simple C++11 constexpr functions in a recent project. While writing unit tests alongside it, I quickly realised that it would be very helpful to have code which verifies that a constexpr function is actually being evaluated at compile-time. It turns out that it’s remarkably easy to do.
Read more How to check that a function is constexpr