Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with defining conditional define.
Forum Updated to NodeBB v4.3 + New Features

Problem with defining conditional define.

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 2.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wodzu
    wrote on last edited by Wodzu
    #1

    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.

    As above so below...

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • W Offline
        W Offline
        Wodzu
        wrote on last edited by
        #3

        Thank you mrjj.

        Indeed, it works in newly created project, so why it does not work in my main project? :/

        As above so below...

        1 Reply Last reply
        0
        • W Offline
          W Offline
          Wodzu
          wrote on last edited by
          #4

          Ok, it works now. Probably a QT bug, I had to reload project.

          Thank you for trying to help.

          As above so below...

          mrjjM 1 Reply Last reply
          0
          • W Wodzu

            Ok, it works now. Probably a QT bug, I had to reload project.

            Thank you for trying to help.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

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

            W 1 Reply Last reply
            0
            • mrjjM mrjj

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

              W Offline
              W Offline
              Wodzu
              wrote on last edited by
              #6

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

              As above so below...

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                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.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                3

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved