Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Trusted Contributor
Brennan12325
Posts: 204
Registered: ‎05-15-2012
My Device: None
My Carrier: Telus
Accepted Solution

Debug Symbols

int main(int argc, char *argv[])
{

#ifdef DEBUG
    printf("RUNNING DEBUG BUILD");
#else
    printf("Running... this is a release build.");
#endif
...

 

How would I go about adding a DEBUG environment variable/ compiler flag/debug symbol that could be used like in the example above? I'm not sure I can just add it to the generated makefiles, since, well, they're generated. Perhaps it should  be added somewhere in the .pro file?

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!
Please use plain text.
Developer
Zmey
Posts: 1,511
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Debug Symbols

[ Edited ]

QT_NO_DEBUG is already defined for release builds (QT_DEBUG for debug builds).

 

You can add your own defines in .pro file like this:

debug {
  DEFINES += MY_DEBUG
}
release {
DEFINES += MY_RELEASE
}

 Or even define macros with values:

VERSION = 1.0.0
DEFINES += APP_VERSION=\\\"$$VERSION\\\"

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Trusted Contributor
Brennan12325
Posts: 204
Registered: ‎05-15-2012
My Device: None
My Carrier: Telus

Re: Debug Symbols

[ Edited ]

So this will have the desired effect, then?

 

#ifdef QT_NO_DEBUG
    int i = 5;
#else   
    qDebug() << "RUNNING DEBUG BUILD";
#endif

top block hit on all release builds (Device-Release, Simulator-Release) bottom block hit on Device-Debug and Simulator-Debug?

 

Edit: Yep that appears to be true. Thanks for the info.

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!
Please use plain text.
Developer
Zmey
Posts: 1,511
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Debug Symbols

[ Edited ]

That's right. Try the following code:

#ifdef QT_DEBUG
#warning Debug build
#endif

#ifdef QT_NO_DEBUG
#warning Release build
#endif

 

p.s.

QT_NO_DEBUG is documented here:

http://doc.qt.digia.com/qt/debug.html

 

There's no mention of QT_DEBUG but I think it's safe to use it too.

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.