Log4cxx
  1. Log4cxx
  2. LOGCXX-83

log4cxx::Level::ERROR fails to compile when GDI enabled

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.10.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows XP, Visual Studio 2005

      Description

      Use of log4cxx::Level::ERROR fails with compilation error in some C++ source files, although DEBUG and INFO compile correctly.

      error C2589 'constant' : illegal token on right side of '::'

      I have tracked it down to the <wingdi.h> header file and managed to avoid the error by using the NOGDI definition. This is okay in my situation, but may cause others problems?

      // fails
      #undef NOGDI
      #include <windows.h>
      ...
      log4cxx::logstream* ls = new log4cxx::logstream(logger, log4cxx::Level::ERROR);

      // works
      #define NOGDI
      #include <windows.h>
      ...
      log4cxx::logstream* ls = new log4cxx::logstream(logger, log4cxx::Level::ERROR);

      Chris

        Activity

        Hide
        Curt Arnold added a comment -

        Same thing can occur with DEBUG, there is a comment in log4cxx/level.h that describes the problem. The best solution I've come up with is to use log4cxx::Level::getError() instead of log4cxx::Level::ERROR. Static member variables are trouble due to initialization sequence issues and should be avoided, but removing these Level::ERROR et al member variables would break too much code. They are there, but if you can, use the functionally equivalent getError() et al methods.

        Within the level.h header, any preexisting definition of DEBUG or ERROR is temporary undef'd and restored. It would not be appropriate for the level.h header to change the definition.

        Reopen this issue if you can come up with a better solution.

        Show
        Curt Arnold added a comment - Same thing can occur with DEBUG, there is a comment in log4cxx/level.h that describes the problem. The best solution I've come up with is to use log4cxx::Level::getError() instead of log4cxx::Level::ERROR. Static member variables are trouble due to initialization sequence issues and should be avoided, but removing these Level::ERROR et al member variables would break too much code. They are there, but if you can, use the functionally equivalent getError() et al methods. Within the level.h header, any preexisting definition of DEBUG or ERROR is temporary undef'd and restored. It would not be appropriate for the level.h header to change the definition. Reopen this issue if you can come up with a better solution.

          People

          • Assignee:
            Curt Arnold
            Reporter:
            Chris Storah
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development