This is an automated email from the ASF dual-hosted git repository.

swebb2066 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git


The following commit(s) were added to refs/heads/master by this push:
     new d9433fc5 Fix build error when using msys2 gcc 13.2.0 (#293)
d9433fc5 is described below

commit d9433fc5283f3bb41ba151646d2ec8e8037f0b6a
Author: Stephen Webb <[email protected]>
AuthorDate: Tue Nov 21 09:55:50 2023 +1100

    Fix build error when using msys2 gcc 13.2.0 (#293)
---
 CMakeLists.txt                       | 2 +-
 src/examples/cpp/com/foo/config3.cpp | 8 ++++++--
 src/main/resources/CMakeLists.txt    | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c2cd2c0e..cb4a0feb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -156,7 +156,7 @@ if(LOG4CXX_QT_SUPPORT)
     )
 endif(LOG4CXX_QT_SUPPORT)
 
-IF(WIN32 AND BUILD_SHARED_LIBS AND LOG4CXX_INSTALL_PDB)
+IF(MSVC AND BUILD_SHARED_LIBS AND LOG4CXX_INSTALL_PDB)
   INSTALL(FILES $<TARGET_PDB_FILE:log4cxx>
           DESTINATION ${CMAKE_INSTALL_BINDIR}
           CONFIGURATIONS RelWithDebInfo Debug
diff --git a/src/examples/cpp/com/foo/config3.cpp 
b/src/examples/cpp/com/foo/config3.cpp
index 34974051..c980248f 100644
--- a/src/examples/cpp/com/foo/config3.cpp
+++ b/src/examples/cpp/com/foo/config3.cpp
@@ -28,8 +28,10 @@
 #include <Windows.h>
 #elif __APPLE__
 #include <mach-o/dyld.h>
+#elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500) || 
(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)
+#include <unistd.h> // getpid
 #else
-#include <unistd.h>     /* getpid */
+#include <cstring> // strncpy
 #endif
 
 
@@ -51,12 +53,14 @@ auto DefaultConfigurationFileNames(std::string& altPrefix) 
-> std::vector<std::s
        pathSepar = '\\';
 #elif defined(__APPLE__)
        _NSGetExecutablePath(buf, &bufCount);
-#else
+#elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500) || 
(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)
        std::ostringstream exeLink;
        exeLink << "/proc/" << getpid() << "/exe";
        bufCount = readlink(exeLink.str().c_str(), buf, bufSize);
        if (0 < bufCount)
                buf[bufCount] = 0;
+#else
+       strncpy(buf, "auto-configured", bufSize);
 #endif
        std::string programFileName(buf);
        auto slashIndex = programFileName.rfind(pathSepar);
diff --git a/src/main/resources/CMakeLists.txt 
b/src/main/resources/CMakeLists.txt
index ce653e55..dfcc89dd 100644
--- a/src/main/resources/CMakeLists.txt
+++ b/src/main/resources/CMakeLists.txt
@@ -16,7 +16,7 @@
 #
 
 # Configure
-if(WIN32)
+if(MSVC)
 target_sources(log4cxx
   PRIVATE
   ../resources/log4cxx.rc

Reply via email to