Use uint32 in GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET macro

There have been some reports that this necessary to prevent build
failures in some environments. It makes sense to do this anyway since
the result of this macro is ultimately assigned to uint32 in the
generated code.
pull/2476/head
Adam Cozzette 8 years ago
parent e43f73e099
commit e19f3b5e3a
  1. 2
      src/google/protobuf/generated_message_reflection.h

@ -660,7 +660,7 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection PROTOBUF_FINAL : public Refl
// choose 16 rather than some other number just in case the compiler would // choose 16 rather than some other number just in case the compiler would
// be confused by an unaligned pointer. // be confused by an unaligned pointer.
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \ #define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \
static_cast<int>( \ static_cast< ::google::protobuf::uint32>( \
reinterpret_cast<const char*>( \ reinterpret_cast<const char*>( \
&reinterpret_cast<const TYPE*>(16)->FIELD) - \ &reinterpret_cast<const TYPE*>(16)->FIELD) - \
reinterpret_cast<const char*>(16)) reinterpret_cast<const char*>(16))

Loading…
Cancel
Save