Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-533

cannot use log4cxx header files with clang++

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Resolved
    • 0.11.0
    • 0.11.0
    • Core
    • None
    • Windows 10/ Visual Studio 2019/clang++

    Description

      I initially reported the problem for vcpkg log4cxx package:

      https://github.com/microsoft/vcpkg/issues/19730

      Here's the report text:

      [log4cxx] failure to compile application with clang on Windows/VC2019

      We have an application that uses log4cxx.
      When I compile with clang on Windows VC2019 I observe the following error:
      [...]
      In file included from C:\vcpkg\installed\x64-windows\include\log4cxx/logger.h:30:
      In file included from C:\vcpkg\installed\x64-windows\include\log4cxx/helpers/appenderattachableimpl.h:27:
      In file included from C:\vcpkg\installed\x64-windows\include\log4cxx/spi/appenderattachable.h:30:
      C:\vcpkg\installed\x64-windows\include\log4cxx\appender.h(140,1): error : explicit instantiation of 'allocator' not in a namespace enclosing 'std'
      LOG4CXX_LIST_DEF(AppenderList, AppenderPtr);
      ^
      C:\vcpkg\installed\x64-windows\include\log4cxx\log4cxx.h(91,45): note: expanded from macro 'LOG4CXX_LIST_DEF'
      extern template class LOG4CXX_EXPORT std::allocator;
      ^
      C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.27.29110\include\iosfwd(167,7): note: explicit instantiation refers here
      class allocator;
      ^

      I found this error appears because clang compiler included with Visual Studio has _MSC_VER macro defined.
      (Intel icx compiler also has _MSC_VER macro defined on Windows)

      The simple fix worked for me for both compilers:
      (log4cxx.h, line 81)

      #elif defined(_MSC_VER) && !defined(__clang__) && !defined(LOG4CXX_STATIC)

      I didn't try to compile with LOG4CXX_STATIC defined, though.

      vcpkg folks recommended to address "upstream" team.

      Attachments

        Activity

          People

            Unassigned Unassigned
            SergeiDelov Sergei Delov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: