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. #ifdef QT_DEBUG always true
Forum Updated to NodeBB v4.3 + New Features

#ifdef QT_DEBUG always true

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 464 Views 1 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.
  • A Offline
    A Offline
    angela2016
    wrote on last edited by
    #1

    Hi,

    all of a sudden #ifdef QT_DEBUG is always true, whether I build in debug or release mode. This is true for all my mayor programs and - of course - it works just fine with a fresh project. I know it worked until at least last month in all of my programs, but I can't possibly remember all the things I've changed since then and I probably wouldn't have noticed immediately, so I have no idea what caused this.

    Any ideas? Thanks.

    Best wishes,
    Angela

    1 Reply Last reply
    0
    • A Offline
      A Offline
      angela2016
      wrote on last edited by
      #2

      OK, never mind. It was a rogue CONFIG += debug in a library shared by all programs.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Shankarlinga M
        wrote on last edited by
        #3

        t looks like the issue was caused by the rogue CONFIG += debug line in a shared library. This configuration line forces the project to always build in debug mode, which would explain why #ifdef QT_DEBUG was always true, regardless of whether you were building in debug or release mode.

        To fix this, simply remove or comment out the CONFIG += debug line from the library's .pro file (or any other configuration file that's shared by all your programs) and rebuild the project. This will allow the build mode to switch between debug and release as expected, and the #ifdef QT_DEBUG directive will work as intended.

        Christian EhrlicherC 1 Reply Last reply
        0
        • S Shankarlinga M

          t looks like the issue was caused by the rogue CONFIG += debug line in a shared library. This configuration line forces the project to always build in debug mode, which would explain why #ifdef QT_DEBUG was always true, regardless of whether you were building in debug or release mode.

          To fix this, simply remove or comment out the CONFIG += debug line from the library's .pro file (or any other configuration file that's shared by all your programs) and rebuild the project. This will allow the build mode to switch between debug and release as expected, and the #ifdef QT_DEBUG directive will work as intended.

          Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Shankarlinga-M No need to reply with AI-generated answers when the op already found out what went wrong...

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          3
          • S Offline
            S Offline
            Shankarlinga M
            wrote on last edited by
            #5

            @Christian-Ehrlicher actually i took from Stackoverflow not ai generated ,BuildConfig.DEBUG is not working (= logically set to false) when I run my app in debug mode. I use Gradle to build. I have a library project where I do this check. BuildConfig.java looks like this in the build debug folder:

            /** Automatically generated the file. DO NOT MODIFY */
            package common.myProject;

            public final class BuildConfig {
            public static final boolean DEBUG = Boolean.parseBoolean("true");

            }
            and in the release folder:

            public static final boolean DEBUG = false;
            both in the library project and in the application project.

            I tried to get around this by checking a variable which is set a class of my project. This class inherits from the library and starts on startup.

            <application
            android:name=".MyPrj" ...
            This leads to another problem: is that I use my DEBUG variable in a DataBaseProvider which runs before the application class, and it will not run properly due to this bug.

            1 Reply Last reply
            0
            • Axel SpoerlA Offline
              Axel SpoerlA Offline
              Axel Spoerl
              Moderators
              wrote on last edited by
              #6

              @Shankarlinga-M
              Two remarks:

              • When you quote something from a foreign source, link it and mark it as a quote. Don't make it look as if it was your own creation.
              • Ever seen that:2eb06185-a8ba-4055-b61d-401cd1a69f5b-image.png
                It formats your code snippets and makes them so much easier to read for everybody else!

              Software Engineer
              The Qt Company, Oslo

              1 Reply Last reply
              3
              • A angela2016 has marked this topic as solved on
              • S Offline
                S Offline
                Shankarlinga M
                wrote on last edited by Shankarlinga M
                #7

                @Axel-Spoerl Thank you for your feedback! I understand the importance of properly quoting and linking sources, and I'll make sure to follow this guideline in the future.
                Regarding code formatting, I appreciate the suggestion. I'will use the correct formatting to make my code snippets clearer and more readable for everyone. Thanks again for the guidance

                1 Reply Last reply
                0

                • Login

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