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.


  • Qt Champions 2016

    Hi
    Try in a test project
    your code works here
    alt text



  • 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.


  • Qt Champions 2016

    @Wodzu
    well normally it works when running qmake manually. Seems you had
    a more stubborn case :)



  • @mrjj

    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:)


  • Lifetime Qt Champion

    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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.