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
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

DEBUG preprocessor definition

Does anyone know if there is a standard preprocessor variable that gets defined when the build configuration is in a debug mode?

 

I've seen things referenced around the internet of using #ifdef _DEBUG but it wasnt ever specific to qnx so not sure if thats the right direction. Anyone have any idea?

Like all of my posts
Developer
Posts: 292
Registered: ‎07-25-2008
My Device: Passport

Re: DEBUG preprocessor definition

I was curious about the same thing, so I decided to tinker a bit.  If you pass "-dM -E" to gcc (including the NDK's variant), it'll spit out the preprocessor directives in use.  (as opposed to "-c" to compile)  Using this method on the compile lines for one of my BB10 projects, I captured output for both arm/release and arm/debug builds.

 

 

$ diff main-rel.txt main-dbg.txt
1c1
< #define METHOD(a) "0"#a
---
> #define METHOD(a) qFlagLocation("0"#a QLOCATION)
744c744
< #define QPLUGIN_DEBUG_STR "false"
---
> #define QPLUGIN_DEBUG_STR "true"
784c784
< #define SIGNAL(a) "2"#a
---
> #define SIGNAL(a) qFlagLocation("2"#a QLOCATION)
895a896
> #define __GCC_HAVE_DWARF2_CFI_ASM 1
1208a1210
> #define QLOCATION "\0" __FILE__ ":" QTOSTRING(__LINE__)
1256d1257
< #define QT_NO_PAINT_DEBUG
1321c1322
< #define Q_ASSERT_X(cond,where,what) qt_noop()
---
> #define Q_ASSERT_X(cond,where,what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop())
1498c1499
< #define Q_ASSERT(cond) qt_noop()
---
> #define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop())
1796c1797
< #define QPLUGIN_SECTION_DEBUG_STR ""
---
> #define QPLUGIN_SECTION_DEBUG_STR ".debug"
1848c1849
< #define QSHAREDPOINTER_VERIFY_AUTO_CAST(T,X) qt_noop()
---
> #define QSHAREDPOINTER_VERIFY_AUTO_CAST(T,X) qt_sharedpointer_cast_check(static_cast(0))
1900c1901
< #define SLOT(a) "1"#a
---
> #define SLOT(a) qFlagLocation("1"#a QLOCATION)
1999d1999
< #define QT_NO_DEBUG 1
2207a2208
> #define __NO_INLINE__ 1
2208a2210
> #define QT_DEBUG
2288d2289

 

From this output, as far as I can tell, the only useful directive to check for is "QT_DEBUG".  Of course I'm not sure you'd really want to use that for this purpose.  I think the solution we're just going to have to come up with, is to make up our own preprocessor directives for the different build configurations.  Those can go into the .pro file, so they get placed in the generated Makefiles.