[glog] Avoid including Windows.h (#24538)

* Fix building errors of glog

* Bump the port version of glog

* Update version database

* Fix building errors

* Update version database
This commit is contained in:
WhuAegeanSea 2022-06-07 04:22:22 +08:00 committed by GitHub
parent 904a51f8e5
commit fdeea72bb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 62 deletions

View File

@ -0,0 +1,17 @@
diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in
index 3ecacfb..2d48a0e 100644
--- a/src/glog/logging.h.in
+++ b/src/glog/logging.h.in
@@ -100,6 +100,12 @@
#include <gflags/gflags.h>
#endif
+#ifdef GLOG_OS_WINDOWS
+#ifndef HAVE_CXX11_ATOMIC
+#define HAVE_CXX11_ATOMIC
+#endif
+#endif
+
#ifdef HAVE_CXX11_ATOMIC
#include <atomic>
#elif defined(GLOG_OS_WINDOWS)

View File

@ -1,59 +0,0 @@
diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in
index 3ecacfb..42cc9b1 100644
--- a/src/glog/logging.h.in
+++ b/src/glog/logging.h.in
@@ -103,6 +103,18 @@
#ifdef HAVE_CXX11_ATOMIC
#include <atomic>
#elif defined(GLOG_OS_WINDOWS)
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN // We only need minimal includes
+# endif
+// To avoid macro definition of ERROR.
+# ifndef NOGDI
+# define NOGDI
+# endif
+// To avoid macro definition of min/max.
+# ifndef NOMINMAX
+# define NOMINMAX
+# endif
+
#include <Windows.h>
#endif
@@ -1061,7 +1073,7 @@ namespace google {
#elif defined(GLOG_OS_WINDOWS)
#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
- static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
+ static volatile unsigned LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
InterlockedIncrement(&LOG_OCCURRENCES); \
if (InterlockedIncrement(&LOG_OCCURRENCES_MOD_N) > n) \
InterlockedExchangeSubtract(&LOG_OCCURRENCES_MOD_N, n); \
@@ -1071,7 +1083,7 @@ namespace google {
&what_to_do).stream()
#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
- static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
+ static volatile unsigned LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
InterlockedIncrement(&LOG_OCCURRENCES); \
if (condition && \
(InterlockedIncrement(&LOG_OCCURRENCES_MOD_N) || true) && \
@@ -1082,7 +1094,7 @@ namespace google {
&what_to_do).stream()
#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
- static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
+ static volatile unsigned LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
InterlockedIncrement(&LOG_OCCURRENCES); \
if (InterlockedIncrement(&LOG_OCCURRENCES_MOD_N) > n) \
InterlockedExchangeSubtract(&LOG_OCCURRENCES_MOD_N, n); \
@@ -1092,7 +1104,7 @@ namespace google {
&what_to_do).stream()
#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
- static int LOG_OCCURRENCES = 0; \
+ static volatile unsigned LOG_OCCURRENCES = 0; \
if (LOG_OCCURRENCES <= n) \
InterlockedIncrement(&LOG_OCCURRENCES); \
if (LOG_OCCURRENCES <= n) \

View File

@ -8,7 +8,7 @@ vcpkg_from_github(
glog_disable_debug_postfix.patch
fix_glog_CMAKE_MODULE_PATH.patch
fix_log_every_n.patch
nogdi-nominmax.patch
fix-windows-CXX11_ATOMIC.patch
fix_crosscompile_symbolize.patch
)

View File

@ -1,7 +1,7 @@
{
"name": "glog",
"version": "0.5.0",
"port-version": 3,
"port-version": 4,
"description": "C++ implementation of the Google logging module",
"homepage": "https://github.com/google/glog",
"license": "BSD-3-Clause",

View File

@ -2570,7 +2570,7 @@
},
"glog": {
"baseline": "0.5.0",
"port-version": 3
"port-version": 4
},
"gloo": {
"baseline": "20201203",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "bb5f54eba990cc0f03c64e1d09f343dd6cd7b22b",
"version": "0.5.0",
"port-version": 4
},
{
"git-tree": "ecb04a5ba4d046af782f62ae7c167bd05b0101a8",
"version": "0.5.0",