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

MSVC: Categorized logging macro causes warning message about scope of variable 'enabled' if function has such a variable

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.3.0
    • 5.3.0
    • Core: I/O
    • None
    • Windows, MSVC

    Description

      Consider

      void SomeClass:setDropSiteEnabled(bool enabled)
      {
          qCDebug(lcQpaMime) << __FUNCTION__ << window() << enabled;
          if (enabled) {
      

      causes

      foo.cpp:984: warning: C4258: 'enabled' : definition from the for loop is ignored; the definition from the enclosing scope is used
      

      since

      #define qCDebug(category, ...) \
          for (bool enabled = category().isDebugEnabled(); Q_UNLIKELY(enabled); enabled = false) \
              QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).debug(__VA_ARGS__)
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kkohne Kai Köhne
            kleint Friedemann Kleint
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes