C++

Cppdepend: measure defects (code smells), cyclomatic complexity …

Written by  on September 21, 2018

As every one knows: I am a fan of objective measurements in the quality and quantity of code. Another nice statistics-generator for such a task is: cppdepend (trial is free for the first month).

It can detect some mistakes and deviations from common coding guidelines (like MISRA) and supports your judgment with some figures.
Cullendula for instance has the estimated development effort of 13 days (right now, v0.4.1) and a technical debt-rating of A. Which is great! 🙂


Qt5: connect: How to use ‘connect’ in case the slot has less parameters than the signal

Written by  on September 18, 2018

Task is to connect from one signal with one parameter to a slot with zero parameters. With the “old” Qt4-way of connect it works like this

But what if I want to use the type-safe Qt5-connects?

The documentation just mentions the cases with:
* connect to default parameters in slot
* and (for example) using the above-mentioned way of the string-based connect.

My idea was to use a lambda to fix this:

But it turned out in in this thread that

is possible! 🙂

Linux Mint 17.3: upgrade CMake

Written by  on September 3, 2018

Ok, cmake 2.8 was installed – I need 3.0. At least. For C++11 features.
The good old Ubuntu-forum helped. This is the condensed version:

Patterns, idioms, whatchamacallit?

Written by  on September 3, 2018

Had first an interesting discussion if you can call the “patterns” we use patterns. Or if there are no “patterns” in software-development, just “idioms”. Of course, quite academical question.
But it reminded me to remove the dust & spider-webs from my own knowledge and refresh it a bit. What’s better than doing it with some C++17 – support?

The other book was just referenced in some software architecture-book. Interesting collection of anecdotes. I can confirm half of the given examples as “seen in real life and projects” ..

First pull-request on github, yay!

Written by  on August 5, 2018

Searched for a usable NTP-library, which assorts well with Qt and stumbled over qntp. While fiddling around I noticed in their source some opportunities to improve the code. So I cloned the repo, did them and created my very first pull-request for open-source 🙂
(Side-note: currently mostly Python-code is pushed due to the daily coding-challenge. But C++/Qt is still my carthorse.)

ESP32: first hands on MAX7219 and WiFi

Written by  on May 29, 2018

For an investment of 80-90 minutes time I am quite happy about the result and amazed what sohisticated capabilites are offered at some really easily accessible level.
What has been achieved so far?
* setting up a working Arduino Studio 1.8.5-environment with ESP32-toolchain on a Win7-laptop (not my favorite, but Linux-PC was blocked)
* setting proper options to the IDE to make the examples compile and upload via serial to the board; learn how to use the integrated serial-monitor
* finding the proper PIN-setup for the MAX7219-LED-display (just one module – for now) and setting up the library
* playing around with the WiFi-functionality (scanning for networks)
* putting both tasks (network scan and led-output) together and running into the first “I need threads”-pit


[Video was taken at an early stage: a static string is displayed.]

Of course, THIS is nothing, just the very first tiny baby-step. Everyone is able to achieve this, because almost no creativity needs to be invested.
But: configuring all the necessary tools was already a pain in the ass. Of course, just read the manual(s) [..]
But this is not a “unwrap and press start”-toy, so the learning-curve was steeper than expected.
But I did it. And I look forward. Especially to put some threaded application on the MCU, because – why just run one thread, when you can have two? 😉

[The MAX7219 and the ESP32-dev-board from MakerHawk hours before the first test run. Battery pack not included.]

MPC: adding additional DEFINES

Written by  on May 25, 2018

Some weeks ago I noticed how the qDebug()-output could be enriched, so that in bigger solutions with a lot of different “unknown” components a reported error could be immediately pinned. And you save writing always __FILE__ and __LINE__. Referres to this post.
But the problem was that with the mpc-buildsystem it was unknown to me how to force it to put this DEFINE into the vcxproj-files.

It can be done via the “macros”-statement!

So I worked on my Python-skills and wrote a short script which iterates the given path recursively and fixes all mpc-files by checking for the position of the line with the last closingbrace “}” and then it adds before that position the line. Of course, the experts know several thousand ways to improve that script – but I am currently happy with it. It works, it is debug-able (.sh, I look at you!) and I will use the skeleton also for some other tasks.
It can be found (like most Python-snippets) at: https://github.com/marcelpetrick/pythonCollection

Preventing the crash of the performance-profiler from Visual Studio (2013-2017) due to Meltdown-/Spectre-patches

Written by  on May 24, 2018

I needed some analytical help from Visual Studio (due to the fact that MTuner and AQTimer could not work properly with our suite). So, I build my solution, fire up the “Performance Profiling” in VS2015 and *zump* computer reboots.
Discussions and investigations led to the thesis that some Windows-patches are the culprit, because they prevent that previously used hooks are usable.
So, setting those two lines in an admin-enabled cmd.exe (plus reboot) lead to alleviation:

static code analysis: PVS Studio

Written by  on May 4, 2018

I am using a new static code analysis-tool for some weeks now and it turns out quite handy: PVS Studio.
It integrates quite well into Visual Studio and you can run the analysis of projects or the whole solution. Doing this can take a while, because all includes are analyzed as well – which is nice. For a single developer a trial-license is for evaluation enough – if you can refrain from the really nice “jump to the culprit”-functionality.
It looks like it detects more errors than cppcheck (another tool which I use now for years on several platforms) and without doubt: none of the reported lines were false positives!

Of course, there is always the discussion with colleagues if those tools help. But I will repeat it again: why not buy & apply them and get a lot of troubleshooting for zero investment of creativity and time!
The screenshot hints out (for instance) that some breaks are missing in the switch-case – and yes, the resulting symptoms were already reported as bug in JIRA.

QT_MESSAGELOGCONTEXT: more detailed qDebug()

Written by  on April 19, 2018

Add to your environment:

Windows: set either via “set” or via RapidEnvironmentEditor.
In case of a no-debug-build, add QT_MESSAGELOGCONTEXT to DEFINES in the pro-file.

(Open question: if there are just mpc/vcxproj-files, then how to trigger?)

related sources:
* https://woboq.com/blog/nice-debug-output-with-qt.html
* https://fecub.wordpress.com/2015/11/04/better-debug-output-using-qt_message_pattern/
* http://doc.qt.io/qt-5/qmessagelogcontext.html#details