-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[glog] fix not work on c++03 #25155
Merged
Merged
[glog] fix not work on c++03 #25155
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 13c474b..34ffc06 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -398,6 +398,14 @@ if (HAVE_EXECINFO_H) | ||
set (HAVE_STACKTRACE 1) | ||
endif (HAVE_EXECINFO_H) | ||
|
||
+if (HAVE_CXX11_ATOMIC) | ||
+ message(STATUS "have atomic") | ||
+ set (ac_cv_cxx11_atomic 1) | ||
+else () | ||
+ message(STATUS "not have atomic") | ||
+ set (ac_cv_cxx11_atomic 0) | ||
+endif () | ||
+ | ||
if (WITH_SYMBOLIZE) | ||
if (WIN32 OR CYGWIN) | ||
if(CMAKE_CROSSCOMPILING) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in | ||
index 3ecacfb..033230d 100644 | ||
--- a/src/glog/logging.h.in | ||
+++ b/src/glog/logging.h.in | ||
@@ -100,10 +100,18 @@ | ||
#include <gflags/gflags.h> | ||
#endif | ||
|
||
-#ifdef HAVE_CXX11_ATOMIC | ||
+#if @ac_cv_cxx11_atomic@ | ||
#include <atomic> | ||
#elif defined(GLOG_OS_WINDOWS) | ||
+// To avoid macro definition of ERROR. | ||
+// To avoid macro definition of min/max. | ||
+# ifndef NOMINMAX | ||
+# define NOMINMAX | ||
+# endif | ||
#include <Windows.h> | ||
+# ifdef ERROR | ||
+# undef ERROR | ||
+# endif | ||
#endif | ||
|
||
@ac_google_start_namespace@ | ||
@@ -1061,7 +1069,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 +1079,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 +1090,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 +1100,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) \ | ||
jiayuehua marked this conversation as resolved.
Show resolved
Hide resolved
|
||
InterlockedIncrement(&LOG_OCCURRENCES); \ | ||
if (LOG_OCCURRENCES <= n) \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that you have removed
NOGDI
, isNOMINMAX
necessary here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember some ports will build fail if not define NOMINMAX. Maybe I can delete it and see if CI report error. The old error log #22135 (comment) I can't download.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the definition of
NOGDI
can fix the build error ofcolmap
, but CI of vcpkg will fail because of the macro ERROR defined in windows.h. It means that the macro ERROR defined in windows.h will get conflicts with other libs like rocksdb.Including windows.h in glog is only to support C++03 on windows, and vcpkg only support C++14(C++11?) or above on windows. glog version less than 0.5 does not contain windows.h, and there are no errors when building colmap via vcpkg.
Beside, including windows.h in glog means many macros like MIN, MAX will be exported, and macros like NOMINMAX should be defined when using functions std::min/max.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jiayuehua @Adela0814