C++

C++ name demangling

Written by  on November 20, 2019

Like described in “Today I learned” (TIL): c++filt is quite helpful for demangling:

But what if you have none readily available? -> c++filtjs

Three ways to find the location of a certain DLL at Windows

Written by  on November 11, 2019

Common problem: just using the current working directory is not sufficient, because especially for unit-tests started from the Visual Studio-testrunner the opriginal, relative path is not fitting anymore. Fallback would be check an environment variable , which is set during installation or using the WinAPI (ugh).

versioned code can be found at: github/cppcCollection

Visual Studio 2015: error LINK1158 rc.exe not found

Written by  on October 22, 2019

Challenge: Visual Studio 2015, Windows Kit 8 and 10 installed, test application (as solution) for a SDK not buildable
Solution:
copy rc.exe and rcdll.dll from
C:\Program Files (x86)\Windows Kits\8.1\bin\x64
to
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

Visual Studio testrunner still running … and stopping you from accessing DLLs for linking

Written by  on October 8, 2019

Problem Challenge:
Several instances of vstest.executionengine.clr20.exe are still running, despite closing that nice Visual Studio 2015 and therefore the access to compile and link several DLLs with QtCreator is blocked.
Closing them one by one with the taskmanager is annoying.

Solution:
* CMD as admin
* $ taskkill /IM vstest.executionengine.clr20.exe /T /F
* or: $ wmic process where name=’vstest.executionengine.clr20.exe’ delete

QTest: increase the timeout duration for a test-case

Written by  on October 7, 2019

Set via environment variable QTEST_FUNCTION_TIMEOUT a higher timeout duration.
qputenv sets them temporary for the run of the single test case (put this at the beginning of the test case).

nota bene: This block has to be put before qExec is ran, so put it into the constructor of the test-suite!

Qt: libpng warning (exception) about wrong color profile (sRGB)

Written by  on October 1, 2019

Problem: libpng warning: iCCP: known incorrect sRGB profile

When debugging Qt applications which load some PNG as icons at startup, it could be annoying to continue with the debugger for each thrown exception.
So, let us fix them.

Invoking $ mogrify *.png in the icon directory will fix them.

How to get mogrify? Install imagemagick.
Either manually or on macOS via homebrew: $ brew install imagemagick

libPNG in version 1.6 has to be at least installed: $ convert -list format | grep PNG

Qt: Error: Not a signal or slot declaration

Written by  on September 4, 2019

This error is too ‘good’ to be just put into “Today I learned”.

While adapting some unit-testing-code for one of the classes, I received from minGW a error stating:

What is the problem? The member-declaration looked totally valid.
Until I realized I had removed the (now commented) “private”-statement and therefore the pointers were seen by the MOC as signals/slots. Which they weren’t!

Shame on me :’)

Heltec WifiKit 8

Written by  on June 11, 2019

Ordered myself two Wifikit8 Esp8266-based boards from Aliexpress.
Received them after roundabout two weeks and now the fun can start.

With the integrated 0.91″ display (128×32 Pixel) a lot of effort for integrating some display or LEDs can be saved. Just noticed that a LiPo-charger is built-in as well, wow. For 4,50 € not a bad choice. But I am not 100% sure if this is the real device or some copycat – nevertheless: in the end the functionality matters.

First project-idea is to create an extended and verifyable version of the random-reviewer. With display of the currently chosen person, a big buzzer-button as trigger and a web-interface for those who doubt the true randomness ..

good guides:

Qt: clean includes

Written by  on May 20, 2019

(I’ve decided to follow a more agile workflow: instead of creation a “one post covers the whole topic”-post, to post also updates for each step. Article will be therefore edited while “doing”)

Last week I’ve cleaned Qt-includes for a larger project. Like #include to #include how it should be. With proper indirection, so that the Qt-library handles how and where the class is implemented.
A colleauge raised the question, why not use #include to be even more precise and to see the used module directly (needed for the CMakeLists or qmake).

First step: identify all used Qt-includes

Greps all includes starting with an uppercase Q; then split the result at the “:”; then sort und make it unique

Second step: create a replacement-list and a (python?) script which does this for all .h/.cpp-files
tdb

C++: proper init for double/float and the proper check

Written by  on May 9, 2019

Problem was that I initialized some doubles with 0.0 and then hoped that the imported values are assigned, which does not happen always. So a check was needed. But checking if(0.0 == x) is a really bad idea. MinGW will tell you too (as other compilers).
So I was searching for a proper way to check against 0.0. And then I found a better idea: initialize with NaN and use the standard-check against this. Much better!

(addendum: I know, a variant would be the best to fix the given task.)