Просмотр исходного кода

Fixing warning under Clang 6.x (-Wexpansion-to-defined) where the macro expansion producing 'defined' was warning on undefined behavior.

drivehappy 8 лет назад
Родитель
Сommit
a23e198cca
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      src/google/protobuf/stubs/port.h

+ 5 - 2
src/google/protobuf/stubs/port.h

@@ -256,8 +256,11 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF);
 # define GOOGLE_PROTOBUF_USE_UNALIGNED 0
 # define GOOGLE_PROTOBUF_USE_UNALIGNED 0
 #else
 #else
 // x86 and x86-64 can perform unaligned loads/stores directly.
 // x86 and x86-64 can perform unaligned loads/stores directly.
-# define GOOGLE_PROTOBUF_USE_UNALIGNED defined(_M_X64) || \
-     defined(__x86_64__) || defined(_M_IX86) || defined(__i386__)
+# if defined(_M_X64) || defined(__x86_64__) || defined(_M_IX86) || defined(__i386__)
+#  define GOOGLE_PROTOBUF_USE_UNALIGNED 1
+# else
+#  define GOOGLE_PROTOBUF_USE_UNALIGNED 0
+# endif
 #endif
 #endif
 
 
 #if GOOGLE_PROTOBUF_USE_UNALIGNED
 #if GOOGLE_PROTOBUF_USE_UNALIGNED