mingw
tutorial: include-what-you-use for a cmake/mingw-build on win
tl;dr:
0. Get the latest prebuilt version for Win: version 0.8 (3 years old :/)
1. Put this somewhere into you CMakeLists.txt
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "C:\\include-what-you-use\\bin\\include-what-you-use.exe")
2. Enjoy the overflowing build-output for your legacy-project.
Qt: Error: Not a signal or slot declaration
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:
1 2 3 |
Output ------ C:/Repos/repoName/filename.h:23: Error: Not a signal or slot declaration |
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!
1 2 3 4 5 6 7 8 9 |
.. private Q_SLOTS: void initTestCase( void ); void cleanupTestCase( void ); //private: classA* _serialPort = nullptr; classB* _flickerSensor = nullptr; .. |
Shame on me :’)
C++: proper init for double/float and the proper check
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!
1 2 3 4 5 6 7 8 9 10 |
#include <limits> .. // init them with NaN to prevent later issues double x{std::numeric_limits<double>::quiet_NaN()}; .. if(isnan(x)) { qDebug() << "uninitialized"; // todom remove return false; } |
(addendum: I know, a variant would be the best to fix the given task.)