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
pull/8122/head
Gianni Tedesco 4 years ago committed by Adam Cozzette
parent e8906e4ecd
commit a91adf173b
  1. 6
      src/google/protobuf/io/coded_stream.h
  2. 7
      src/google/protobuf/stubs/port.h

@ -131,7 +131,11 @@
#pragma runtime_checks("c", off)
#endif
#else
#include <sys/param.h> // __BYTE_ORDER
#ifdef __APPLE__
#include <machine/endian.h> // __BYTE_ORDER
#else
#include <endian.h> // __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)

@ -57,9 +57,10 @@
#pragma runtime_checks("c", off)
#endif
#else
#include <sys/param.h> // __BYTE_ORDER
#if defined(__OpenBSD__)
#include <endian.h>
#ifdef __APPLE__
#include <machine/endian.h> // __BYTE_ORDER
#else
#include <endian.h> // __BYTE_ORDER
#endif
#if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \
(defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \

Loading…
Cancel
Save