diff --git a/src/babylon/any.cpp b/src/babylon/any.cpp index 1ebfb09..8285834 100644 --- a/src/babylon/any.cpp +++ b/src/babylon/any.cpp @@ -1,9 +1,6 @@ #include "babylon/any.h" -#pragma clang diagnostic push -#if __clang__ -#pragma clang diagnostic ignored "-Wc++20-designator" -#endif // __clang__ +#include "babylon/protect.h" BABYLON_NAMESPACE_BEGIN @@ -71,4 +68,4 @@ Any& Any::ref(const Descriptor* descriptor, void* instance) noexcept { BABYLON_NAMESPACE_END -#pragma clang diagnostic pop +#include "babylon/unprotect.h" diff --git a/src/babylon/any.h b/src/babylon/any.h index 81d0241..c1cb889 100644 --- a/src/babylon/any.h +++ b/src/babylon/any.h @@ -4,10 +4,7 @@ #include // std::unique_ptr -#pragma clang diagnostic push -#if __clang__ -#pragma clang diagnostic ignored "-Wc++20-designator" -#endif // __clang__ +#include "babylon/protect.h" BABYLON_NAMESPACE_BEGIN @@ -308,6 +305,6 @@ class Any { BABYLON_NAMESPACE_END -#pragma clang diagnostic pop +#include "babylon/unprotect.h" #include "babylon/any.hpp" diff --git a/src/babylon/any.hpp b/src/babylon/any.hpp index 72c576d..25392f2 100644 --- a/src/babylon/any.hpp +++ b/src/babylon/any.hpp @@ -8,10 +8,7 @@ #include // ::assert -#pragma clang diagnostic push -#if __clang__ -#pragma clang diagnostic ignored "-Wc++20-designator" -#endif // __clang__ +#include "babylon/protect.h" BABYLON_NAMESPACE_BEGIN @@ -476,4 +473,4 @@ inline ::std::unique_ptr Any::release() noexcept { BABYLON_NAMESPACE_END -#pragma clang diagnostic pop +#include "babylon/unprotect.h" diff --git a/src/babylon/logging/async_file_appender.cpp b/src/babylon/logging/async_file_appender.cpp index a2905a4..f9caa5a 100644 --- a/src/babylon/logging/async_file_appender.cpp +++ b/src/babylon/logging/async_file_appender.cpp @@ -4,10 +4,7 @@ #include #include -#pragma clang diagnostic push -#if __clang__ -#pragma clang diagnostic ignored "-Wc++20-designator" -#endif // __clang__ +#include "babylon/protect.h" BABYLON_NAMESPACE_BEGIN @@ -149,4 +146,4 @@ void AsyncFileAppender::write_use_plain_writev(Destination& dest, BABYLON_NAMESPACE_END -#pragma clang diagnostic pop +#include "babylon/unprotect.h" diff --git a/src/babylon/logging/log_entry.cpp b/src/babylon/logging/log_entry.cpp index 6c76d56..67e7bb8 100644 --- a/src/babylon/logging/log_entry.cpp +++ b/src/babylon/logging/log_entry.cpp @@ -1,9 +1,6 @@ #include "babylon/logging/log_entry.h" -#pragma clang diagnostic push -#if __clang__ -#pragma clang diagnostic ignored "-Wc++20-designator" -#endif // __clang__ +#include "babylon/protect.h" BABYLON_NAMESPACE_BEGIN @@ -120,4 +117,4 @@ void LogStreamBuffer::overflow_page_table() noexcept { BABYLON_NAMESPACE_END -#pragma clang diagnostic pop +#include "babylon/unprotect.h" diff --git a/src/babylon/logging/log_severity.h b/src/babylon/logging/log_severity.h index 8963073..3bf81e1 100644 --- a/src/babylon/logging/log_severity.h +++ b/src/babylon/logging/log_severity.h @@ -2,6 +2,8 @@ #include "babylon/string_view.h" // StringView +#include "babylon/protect.h" + BABYLON_NAMESPACE_BEGIN class LogSeverity { @@ -33,17 +35,12 @@ class LogSeverity { private: int8_t _value {DEBUG}; -#pragma clang diagnostic push -#if __clang__ -#pragma clang diagnostic ignored "-Wc99-designator" -#endif // __clang__ static constexpr StringView names[NUM] = { [DEBUG] = "DEBUG", [INFO] = "INFO", [WARNING] = "WARNING", [FATAL] = "FATAL", }; -#pragma clang diagnostic pop }; inline constexpr LogSeverity::LogSeverity(int8_t value) noexcept @@ -64,3 +61,5 @@ inline ::std::basic_ostream& operator<<(::std::basic_ostream& os, } BABYLON_NAMESPACE_END + +#include "babylon/unprotect.h" diff --git a/src/babylon/protect.h b/src/babylon/protect.h index 543f525..78cc18e 100644 --- a/src/babylon/protect.h +++ b/src/babylon/protect.h @@ -23,6 +23,11 @@ #pragma push_macro("F") #undef F +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic ignored "-Wunknown-warning-option" +#pragma GCC diagnostic ignored "-Wc99-designator" + #else // BAIDU_PROTECT_H #error("protect.h without unprotect.h") #endif // BAIDU_PROTECT_H diff --git a/src/babylon/unprotect.h b/src/babylon/unprotect.h index f1e6da0..47bbb35 100644 --- a/src/babylon/unprotect.h +++ b/src/babylon/unprotect.h @@ -26,4 +26,6 @@ // 例如baidu/feed-mlarch/feature-extract-framework中定义了F #pragma pop_macro("F") +#pragma GCC diagnostic pop + #endif // BABYLON_UNPROTECT_H diff --git a/test/concurrent/test_sched_interface.cpp b/test/concurrent/test_sched_interface.cpp index 4d12f4d..e120c62 100644 --- a/test/concurrent/test_sched_interface.cpp +++ b/test/concurrent/test_sched_interface.cpp @@ -4,8 +4,7 @@ #include // ::std::async -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wc++20-designator" +#include "babylon/protect.h" using ::babylon::Futex; using ::babylon::SchedInterface; @@ -199,4 +198,4 @@ TEST(futex_interface, futex_value_read_write_as_atomic) { } } -#pragma clang diagnostic pop +#include "babylon/unprotect.h"