Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 23, 2009, 11:29:01 PM (15 years ago)
Author:
rgrieder
Message:

Removed annoying "statement has no effect" warning (gcc).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/libraries/util/Debug.h

    r6105 r6133  
    7373    //! Adjust to discard certain output with level > hardDebugLevel at compile time
    7474    const int hardDebugLevel = OutputLevel::Verbose;
     75
     76    //! This function simply returns 0 and helps to suppress the "statement has no effect" compiler warning
     77    inline int debugDummyFunction()
     78    {
     79        return 0;
     80    }
    7581}
    7682
     
    7985    Logs text output: use exactly like std::cout, but specify an output
    8086    level as argument.
     87@details
     88    (a > b ? 0 : c << "text") is equivalent to (a > b ? 0 : (c << "text"))
     89    where (a > b ? 0 : ) stands for COUT(x). This should explain how
     90    this macro magic can possibly even work ;)
    8191@example
    8292    COUT(3) << "Some info" << std::endl;
     
    8898#define COUT(level)                                                    \
    8999    /*if*/ (level > orxonox::hardDebugLevel) ?                         \
    90         0                                                              \
     100        orxonox::debugDummyFunction()                                  \
    91101    /*else*/ :                                                         \
    92102        /*if*/ (level > orxonox::OutputHandler::getSoftDebugLevel()) ? \
    93             0                                                          \
     103            orxonox::debugDummyFunction()                              \
    94104        /*else*/ :                                                     \
    95105            orxonox::OutputHandler::getOutStream(level)
Note: See TracChangeset for help on using the changeset viewer.