TIL – Today I learned

If there is a type-conversion problem in your code, you get the mangled names: h and j, but for what do they stand?

C++ name demangling can help: c++filt

C++; minGW; undefined reference at link-time even if everything seems right?
Did you forget to add a XYZ_EXPORT flag to the class declaration?

Print readme.md-files (or whatever markup) in a fashionable way: try gitprint by using the github-url to the document and replace github->gitprint.
example: https://gitprint.com/google/googletest/blob/master/googlemock/docs/for_dummies.md?print

macOS names and numbers:

for everyone who preferes numbers over names:
Mac OS X 10.6 Snow Leopard
Mac OS X 10.7 Lion
OS X 10.8 Mountain Lion
OS X 10.9 Mavericks
OS X 10.10 Yosemite
OS X 10.11 El Capitan
macOS 10.12 Sierra
macOS 10.13 High Sierra
macOS 10.14 Mojave <– current
macOS 10.15 Catalina <– upcoming

Creating a smol program which calls some DLL-functions (also C#) results at runtime before even the very first breakpoint is reached something like:
An unhandled exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
Solution: make sure DLLs and code use the same target framework version for .NET! Both 3.5 in my case. Can be done via “solution > properties”.

Save and/or view openCV-mask (image) as picture for evaluation:

Converting from a QVariant-container back to your arbitrary container of custom class:
toList() on non QVariant-convertable items will yield a list of size 0 and this is unexpected when the gdb can show the QVariant’s contents.
Also check that tutorial before worrying again too much xD

Get all findings with grep but without path or line-number:
git grep -h "de <Q"

Sometimes a warning about “Prior to the resolution of a defect report against ISO C++11 ..” a warning by the code-model of QtCreator is given (due to -Wreturn-std-move-in-c++11 ), which can be suppressed by adding a std::move(returnValue) to the return.

Fucked something up? Revert all changes and make sure no artifacts (which are not version-controlled) remain:

Ifdef in InnoSetup-scripts are possible and usable. StackOverflow also mentions that setting their value by commandline should be possible: call with “/DUSE_SPECIALCOMP 1

C# bootcamp continues – learning things the hard and fast way.
Yesterday I broke a lot of tests by just converting structs to classes and adding default inits to the values. Could mbe due to the mix with C-functions ..
Found a way around: keep as struct, but add the default ctor for the struct with optional params for each field. Like:

Special characters for the XML-comments have to be HTML-escaped (or use CDATA): < would be < ..

handling of the IDE (Visual Studio 2015):

  • auto-format code with Visual Studio 2015: CTRL+K, CTRL+F
  • close the current file: CTRL + F4
  • go to the last view: CTRL + –

I made it my task to acquire as much C#-knowledge as possible, because a tiny part of the project is some C# SDK and we needed a volunteer to groom it. Guess who raised his hand? 😉

Before it was applied to a struct, does it work for class too? Documentation says: “You can apply this attribute to classes or structures.
Typically, the common language runtime controls the physical layout of the data fields of a class or structure in managed memory. However, if you want to arrange the class or structure needs in a certain way, you can use StructLayoutAttribute. Explicit control of a class layout is important if the class is to be passed to unmanaged code that expects a specific layout.”

Visual Studio (2015) quick help:
F12 : jump to implementation
CTRL + “-” : go back to last view

More later – maybe I make a real blog-entry out of it.

Even big corporate repositories are not shiny and polished: but this is just another opportunity for me to participate. Found some typos in the documentation of Microsoft’s SymCrypt. Solved it and created a pull request 🙂

Even Qt 5.11 (5.12 is latest, I know) treats big chunks of data with the idea “Oh, size of an object won’t be bigger than what fits into 31 bit” and boom, here hits you the well-known 2 GiByte-limit. This is super annyoing if you use a QByteArray or QDataStream::writeRawData / QDataStream::readRawData.
So I rewrote those calls to separate the data into chunks of 1 GiByte and write/read them sequentially. Works, but somehow felt slower and the code becomes uglier. Bit it works, yay!

Win, Cmake, MinGW, Qt 5.12: suddenly after switching from Qt 5.11 an errror while starting the app popped up: “This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: direct2d, minimal, offscreen, windows.”
Copying the “platforms”-folder to the location where the executable is, did not help (like it should). The Cmake already deploys properly.
Workaround was found via one hidden stackoverflow-comment, because I can’t use the windeploy-tool here.
So: create a file names “qt.conf” with content inside the exe-directory:
Prefix = .

How to reset the state of the filesystem of the git-repo to “just like after checkout”: $ git clean -xfd

QtCreator: Alt+Enter on a member opens the context-menu for refactoring (“Create Setter/Getter functions”). Better this than RMB + clicks for each member.

Parsing XML files with Qt/C++: QXmlQuery was not my way to go – QDomDocument/QDomNodeList and QDomElement were my friends. Example: read node P and put as double into a QVariant.
QDomElement const elemP = node.firstChildElement("P");
QVariant vP = elemP.text().toDouble();

C++ has (now) a quite nice way to determine the supported number of threads: std::thread::hardware_concurrency();
See: https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency

Experienced first time in QtCreator “FTH: (15020): *** Fault tolerant heap shim applied to current process. This is usually due to previous crashes. ***”
Better explanation than I could provide here: https://forum.qt.io/topic/94341/fault-tolerant-heap-shim-error

There is a map where you can check where which SSID (wifi identifier) was found: https://wigle.net/

Visual Studio 2013 (at least) has an integrated ico-file-editor which is quite convenient for painting application-symbols. Integrating it to some qmake-project (Cullendula) was simple.

* C plus equal: the feminist version of C++. Not sure if this is nice, obscure or a joke? I had some good laughs while reading the manual and the examples. https://github.com/TheFeministSoftwareFoundation/C-plus-Equality

* github.io – and how to create my own (https://marcelpetrick.github.io/)
* The void operator()() for C++. Nice for iteration of containers.
* boost::accumulators for easier data-collection: nice for min, max, mean, etc.

20180913: Use a lambda-expression for delayed triggering of a function-call.

20180904: the online-installers for Qt5.11 and Visual Studio 2017 Community Editon will download 18 GiByte during installation :’)

20180903: how to configure and use cmake for an originally qmake-based project. And even the linking works now. More later 🙂

20180826: std-lib has some pretty nice random-number-generators (Mersenne-twister), which can be seeded properly with system-time:

20180824: Lambda-expressions in Qt-slots are quite nice for “one liner”-functions. Saves much space.