Solved Problem with defining conditional define.
-
Hello,
I would like to add a conditional define to my project. So in my .pro file I am adding it like this:
DEFINES += _USE_MATH_DEFINES DEFINES += WG_DEBUG_OBJECT
and then, later in some .cpp file I would like to use it:
#ifdef WG_DEBUG_OBJECT gDebug.Vertices.insert({ { "LP1", LP1 },{ "LP2", LP2 },{ "LP3", LP3 },{ "RP1", RP1 }, { "RP2", RP2 },{ "RP3", RP3 },{ "T1", T1 },{ "T2", T2 },{ "T3", T3 },{ "C", lLakeCenter } }); #endif
The problem is that this code never gets executed, I've tried to rebuild, run QMake and so on. Am I missing something?
I am using Qt Creator 4.1.0
Edit: The funny thing is that when I change #ifdef to #ifndef the code is also not executed...
Thanks.
-
Hi
Try in a test project
your code works here
-
Thank you mrjj.
Indeed, it works in newly created project, so why it does not work in my main project? :/
-
Ok, it works now. Probably a QT bug, I had to reload project.
Thank you for trying to help.
-
@Wodzu
well normally it works when running qmake manually. Seems you had
a more stubborn case :) -
Must be, because I've checked QMake file and I saw that define has been passed there but somehow it does not reflect this after compiling code:)
-
Hi,
When adding or removing a define, you have to do a full rebuild or at least the files that are affected by it. The build system doesn't that a file must be rebuilt because there's no code change.