From 78743e6a55c4c0859a5768cb8b7ffa6971cee232 Mon Sep 17 00:00:00 2001 From: Chunting Gu Date: Thu, 30 May 2019 17:17:50 +0800 Subject: [PATCH] Rename macro WIN32 to _WIN32 --- autotest/client_autotest.cc | 2 +- examples/client_basics.cc | 2 +- examples/file_upload_client.cc | 2 +- examples/github_client.cc | 2 +- examples/rest_book_client.cc | 2 +- examples/rest_book_server.cc | 2 +- webcc/logger.cc | 8 ++++---- webcc/logger.h | 10 ++++++---- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/autotest/client_autotest.cc b/autotest/client_autotest.cc index 262b3fa..92d73ec 100644 --- a/autotest/client_autotest.cc +++ b/autotest/client_autotest.cc @@ -8,7 +8,7 @@ // ----------------------------------------------------------------------------- -#if (defined(WIN32) || defined(_WIN64)) +#if (defined(_WIN32) || defined(_WIN64)) // You need to set environment variable SSL_CERT_FILE properly to enable // SSL verification. bool kSslVerify = false; diff --git a/examples/client_basics.cc b/examples/client_basics.cc index f2dcced..62b314d 100644 --- a/examples/client_basics.cc +++ b/examples/client_basics.cc @@ -3,7 +3,7 @@ #include "webcc/client_session.h" #include "webcc/logger.h" -#if (defined(WIN32) || defined(_WIN64)) +#if (defined(_WIN32) || defined(_WIN64)) // You need to set environment variable SSL_CERT_FILE properly to enable // SSL verification. bool kSslVerify = false; diff --git a/examples/file_upload_client.cc b/examples/file_upload_client.cc index 8f09b87..3380ef0 100644 --- a/examples/file_upload_client.cc +++ b/examples/file_upload_client.cc @@ -5,7 +5,7 @@ #include "webcc/client_session.h" #include "webcc/logger.h" -#if (defined(WIN32) || defined(_WIN64)) +#if (defined(_WIN32) || defined(_WIN64)) // You need to set environment variable SSL_CERT_FILE properly to enable // SSL verification. bool kSslVerify = false; diff --git a/examples/github_client.cc b/examples/github_client.cc index 40bd0d0..768a99b 100644 --- a/examples/github_client.cc +++ b/examples/github_client.cc @@ -10,7 +10,7 @@ // Change to 1 to print response JSON. #define PRINT_RESPONSE 0 -#if (defined(WIN32) || defined(_WIN64)) +#if (defined(_WIN32) || defined(_WIN64)) // You need to set environment variable SSL_CERT_FILE properly to enable // SSL verification. bool kSslVerify = false; diff --git a/examples/rest_book_client.cc b/examples/rest_book_client.cc index 17e6b6a..f764752 100644 --- a/examples/rest_book_client.cc +++ b/examples/rest_book_client.cc @@ -9,7 +9,7 @@ #include "examples/common/book.h" #include "examples/common/book_json.h" -#if (defined(WIN32) || defined(_WIN64)) +#if (defined(_WIN32) || defined(_WIN64)) #if defined(_DEBUG) && defined(WEBCC_ENABLE_VLD) #pragma message ("< include vld.h >") #include "vld/vld.h" diff --git a/examples/rest_book_server.cc b/examples/rest_book_server.cc index bed4a0f..1953a89 100644 --- a/examples/rest_book_server.cc +++ b/examples/rest_book_server.cc @@ -13,7 +13,7 @@ #include "examples/common/book.h" #include "examples/common/book_json.h" -#if (defined(WIN32) || defined(_WIN64)) +#if (defined(_WIN32) || defined(_WIN64)) #if defined(_DEBUG) && defined(WEBCC_ENABLE_VLD) #pragma message ("< include vld.h >") #include "vld/vld.h" diff --git a/webcc/logger.cc b/webcc/logger.cc index 3cb96e4..d807c08 100644 --- a/webcc/logger.cc +++ b/webcc/logger.cc @@ -12,7 +12,7 @@ #include #include -#if (defined(WIN32) || defined(_WIN64)) +#if (defined(_WIN32) || defined(_WIN64)) #include #else // For getting thread ID. @@ -75,7 +75,7 @@ static Logger g_logger; bool g_colorlogtostderr = true; static const bool g_terminal_has_color = []() { -#if (defined(WIN32) || defined(_WIN64)) +#if (defined(_WIN32) || defined(_WIN64)) #ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 #endif @@ -105,7 +105,7 @@ static const bool g_terminal_has_color = []() { // Colors -#if (defined(WIN32) || defined(_WIN64)) +#if (defined(_WIN32) || defined(_WIN64)) #define VTSEQ(ID) ("\x1b[1;" #ID "m") #else #define VTSEQ(ID) ("\x1b[" #ID "m") @@ -166,7 +166,7 @@ namespace bfs = boost::filesystem; // on Linux, e.g., 140219133990656. syscall(SYS_gettid) is much prefered because // it's shorter and the same as `ps -T -p ` output. static std::string DoGetThreadID() { -#if (defined(WIN32) || defined(_WIN64)) +#if (defined(_WIN32) || defined(_WIN64)) auto thread_id = std::this_thread::get_id(); std::stringstream ss; ss << thread_id; diff --git a/webcc/logger.h b/webcc/logger.h index 0547689..b111267 100644 --- a/webcc/logger.h +++ b/webcc/logger.h @@ -47,7 +47,9 @@ void Log(int level, const char* file, int line, const char* format, ...); // Initialize the logger with a level. #define WEBCC_LOG_INIT(dir, modes) webcc::LogInit(dir, modes); -#if (defined(WIN32) || defined(_WIN64)) +// Definition of _WIN32 & _WIN64: +// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2015 +#if (defined(_WIN32) || defined(_WIN64)) // See: https://stackoverflow.com/a/8488201 // ISSUE: The last path separator of __FILE__ in a header file becomes "/" @@ -116,13 +118,13 @@ void Log(int level, const char* file, int line, const char* format, ...); #define LOG_ERRO(format, args...) #endif -#endif // defined(WIN32) || defined(_WIN64) +#endif // defined(_WIN32) || defined(_WIN64) #else // WEBCC_ENABLE_LOG == 0 #define WEBCC_LOG_INIT(dir, modes) -#if (defined(WIN32) || defined(_WIN64)) +#if (defined(_WIN32) || defined(_WIN64)) #define LOG_VERB(format, ...) #define LOG_INFO(format, ...) #define LOG_WARN(format, ...) @@ -132,7 +134,7 @@ void Log(int level, const char* file, int line, const char* format, ...); #define LOG_INFO(format, args...) #define LOG_WARN(format, args...) #define LOG_ERRO(format, args...) -#endif // defined(WIN32) || defined(_WIN64) +#endif // defined(_WIN32) || defined(_WIN64) #endif // WEBCC_ENABLE_LOG