Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-61578

Macros for categoriy logging (e.g. qCDebug) do not compile with "-pedantic -Werror" as they use empty variadic arguments

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 5.6.1
    • Core: Other
    • None
    • {noformat}
      $ clang --version
      Apple LLVM version 8.1.0 (clang-802.0.42)
      Target: x86_64-apple-darwin16.4.0{noformat}

    Description

      The qCDebug(category, ...) macro expands to QMessageLogger(...).debug(_VA_ARGS_). This is fine when using the printf-style syntax but does not compile when using it as stream.

      Happens with clang on Mac. Small reproducer attached - it is enough to use the strem version of qCDebug() in any Qt app and compile with

      -pedantic -Werror

      Workaround: disable the specific diagnostic with

      -Wno-gnu-zero-variadic-macro-arguments

      About the cause: as far as I understand, the macro expansion violates C++11 standard as a variadic macro argument can be empty only if there is the same number of argument in the macro call (while here there's the category, so it's 1).

      A related bug:  QTBUG-37283

      Attachments

        1. CategoryLoggingExample.pro
          1.0 kB
        2. main.cpp
          0.4 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            narcolessico Eugenio Rustico
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes