From 339f622f94426d48a294a1fd41acc96b4479ff2f Mon Sep 17 00:00:00 2001 From: Gianni Tedesco Date: Tue, 1 Dec 2020 08:05:17 +0900 Subject: [PATCH] Don't include sys/param.h for _BYTE_ORDER It includes a bunch of other files including a lot of macros which can reduce the namespace available for actual protobuf. For example, create a protobuf with a member called SIGSEGV. Since macros cannot be namespaced in C++ this results in code which cannot be compiled. Fix this by just directly including endian.h --- src/google/protobuf/io/coded_stream.h | 6 +++++- src/google/protobuf/stubs/port.h | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index 0fff1782cf07..a4d5f960a338 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -131,7 +131,11 @@ #pragma runtime_checks("c", off) #endif #else -#include // __BYTE_ORDER +#ifdef __APPLE__ +#include // __BYTE_ORDER +#else +#include // __BYTE_ORDER +#endif #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \ (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)) && \ !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index db8b62f6b3a4..120ab7e9f427 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -57,9 +57,10 @@ #pragma runtime_checks("c", off) #endif #else - #include // __BYTE_ORDER - #if defined(__OpenBSD__) - #include + #ifdef __APPLE__ + #include // __BYTE_ORDER + #else + #include // __BYTE_ORDER #endif #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \ (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \