From b47bf4c9300c8effa9c93ca1cc5cc51a12c8e119 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Wed, 26 Aug 2015 22:32:04 +0100 Subject: [PATCH 1/2] Assume LITTLE_ENDIAN for windows build. --- src/google/protobuf/stubs/port.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 5158a6f9..55c41685 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -45,12 +45,12 @@ #endif #undef PROTOBUF_LITTLE_ENDIAN -#ifdef _MSC_VER +#ifdef _WIN32 // Assuming windows is always little-endian. #if !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) #define PROTOBUF_LITTLE_ENDIAN 1 #endif - #if _MSC_VER >= 1300 + #if defined(_MSC_VER) && _MSC_VER >= 1300 // If MSVC has "/RTCc" set, it will complain about truncating casts at // runtime. This file contains some intentional truncating casts. #pragma runtime_checks("c", off) From d9f4636818e6f935df98c17d875217210a123917 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Wed, 26 Aug 2015 22:40:41 +0100 Subject: [PATCH 2/2] Add a TODO to clean-up the LITTLE_ENDIAN macro. --- src/google/protobuf/stubs/port.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 55c41685..9ea34cde 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -47,6 +47,9 @@ #undef PROTOBUF_LITTLE_ENDIAN #ifdef _WIN32 // Assuming windows is always little-endian. + // TODO(xiaofeng): The PROTOBUF_LITTLE_ENDIAN is not only used for + // optimization but also for correctness. We should define an + // different macro to test the big-endian code path in coded_stream. #if !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) #define PROTOBUF_LITTLE_ENDIAN 1 #endif