#ifdef QT_DEBUG always true
-
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 -
OK, never mind. It was a rogue CONFIG += debug in a library shared by all programs.
-
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.
-
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.
@Shankarlinga-M No need to reply with AI-generated answers when the op already found out what went wrong...
-
@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. -
@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:
It formats your code snippets and makes them so much easier to read for everybody else!
-
-
@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