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. Prevent qDebug function to be compiled in release mode

Prevent qDebug function to be compiled in release mode

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.7k 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.
  • M Offline
    M Offline
    marcus.fr
    wrote on last edited by
    #1

    Hi

    I use qDebug in relation with QT_NO_DEBUG_OUTPUT in order to suppress debugging in release mode. In release mode I want this function to not be compiled and not just to be a function that does nothing. I wonder if I need to use a macro in order to be sure that QDebug function will not be compiled at all in release mode? I was thinking of something like below:

    @#ifdef QT_DEBUG
    #define MyDebug qDebug
    #else
    #define MyDebug(fmt, arg...) ((void)0)
    #endif@

    Maybe the practice is somewhat different among Qt community.

    1 Reply Last reply
    0
    • W Offline
      W Offline
      WoJo
      wrote on last edited by
      #2

      http://qt-project.org/doc/qt-4.8/qtglobal.html#qDebug

      bq. This function does nothing if QT_NO_DEBUG_OUTPUT was defined during compilation.

      open qdebug.h it returns an empty object.

      @inline QNoDebug qDebug() { return QNoDebug(); }@

      QNoDebug has empty inline functions. there will be no function call overhead...

      1 Reply Last reply
      0
      • M Offline
        M Offline
        marcus.fr
        wrote on last edited by
        #3

        [quote author="WoJo" date="1362672905"]http://qt-project.org/doc/qt-4.8/qtglobal.html#qDebug

        bq. This function does nothing if QT_NO_DEBUG_OUTPUT was defined during compilation.

        open qdebug.h it returns an empty object.

        @inline QNoDebug qDebug() { return QNoDebug(); }@

        QNoDebug has empty inline functions. there will be no function call overhead...[/quote]

        The empty function will probably be removed by the modern compiler, but one cannot be sure for every compiler. I was thinking to use a MACRO to make that certain.

        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