aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/stubs/port.h
diff options
context:
space:
mode:
authorGravatar Hans Wennborg <hwennborg@google.com>2015-08-26 11:24:41 -0700
committerGravatar Hans Wennborg <hans@chromium.org>2015-08-26 11:32:08 -0700
commitfcf1b575799f93d10d030069ba9857af924c31a8 (patch)
tree9848a61beaefcb01f4d6ac7bdd230e528d0ef344 /src/google/protobuf/stubs/port.h
parentf6b05f78a44501ef6a71f842788536f726144120 (diff)
Fix the no-op definitions of GOOGLE_PREDICT_{TRUE,FALSE}
Updating to the current protobuf version caused the following build errors in Chromium when using Clang on Windows: ..\..\third_party\protobuf\src\google/protobuf/stubs/fastmem.h(67,43) : error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality] if (GOOGLE_PREDICT_FALSE(n_rounded_down == 0)) { // n <= 7 ~~~~~~~~~~~~~~~^~~~ The problem is that on Windows, GOOGLE_PREDICT_FALSE is #defined to nothing, so the code expands to 'if ((n_rounded_down == 0))', which Clang warns about. Clang would not have warned if the extra parentheses came from the macro, but in this case they don't because the macro is just dropped. Fix this by making the macros behave as an identity function instead of just getting dropped. This is closer to what these macros look like in stubs/port.h internally.
Diffstat (limited to 'src/google/protobuf/stubs/port.h')
-rw-r--r--src/google/protobuf/stubs/port.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h
index a3c53dd9..52c89005 100644
--- a/src/google/protobuf/stubs/port.h
+++ b/src/google/protobuf/stubs/port.h
@@ -184,7 +184,7 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF);
// Provided at least since GCC 3.0.
#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
#else
-#define GOOGLE_PREDICT_TRUE
+#define GOOGLE_PREDICT_TRUE(x) (x)
#endif
#endif
@@ -193,7 +193,7 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF);
// Provided at least since GCC 3.0.
#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0))
#else
-#define GOOGLE_PREDICT_FALSE
+#define GOOGLE_PREDICT_FALSE(x) (x)
#endif
#endif