summaryrefslogtreecommitdiffstats
path: root/base/logging.h
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-26 16:34:49 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-26 16:34:49 +0000
commit8c1766b9de2d3904aaad7d7631a6d3f59a90b8b0 (patch)
treed0096256922a26f54db8c7cdf5c8e10dbf162ef3 /base/logging.h
parent238a20d1987f93f79895a8f8710ac9912e8d60a0 (diff)
downloadchromium_src-8c1766b9de2d3904aaad7d7631a6d3f59a90b8b0.zip
chromium_src-8c1766b9de2d3904aaad7d7631a6d3f59a90b8b0.tar.gz
chromium_src-8c1766b9de2d3904aaad7d7631a6d3f59a90b8b0.tar.bz2
Make sure variables are referenced in CHECK macros, even for official builds.
Previously the GCC based builds couldn't build with OFFICIAL_BUILD, since code like: bool success = Something(); DCHECK(success); Would result in a compile warning (treated as error) about success being unused. Review URL: http://codereview.chromium.org/18747 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8630 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/logging.h')
-rw-r--r--base/logging.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/base/logging.h b/base/logging.h
index 062ce8e..4fd7641 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -277,41 +277,43 @@ enum { DEBUG_MODE = 0 };
// non-debug mode. The DCHECK and friends macros use this so that
// the expanded expression DCHECK(foo) << "asdf" is still syntactically
// valid, even though the expression will get optimized away.
+// In order to avoid variable unused warnings for code that only uses a
+// variable in a CHECK, we make sure to use the macro arguments.
#define NDEBUG_EAT_STREAM_PARAMETERS \
logging::LogMessage(__FILE__, __LINE__).stream()
#define DCHECK(condition) \
- while (false) NDEBUG_EAT_STREAM_PARAMETERS
+ while (false && (condition)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_EQ(val1, val2) \
- while (false) NDEBUG_EAT_STREAM_PARAMETERS
+ while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_NE(val1, val2) \
- while (false) NDEBUG_EAT_STREAM_PARAMETERS
+ while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_LE(val1, val2) \
- while (false) NDEBUG_EAT_STREAM_PARAMETERS
+ while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_LT(val1, val2) \
- while (false) NDEBUG_EAT_STREAM_PARAMETERS
+ while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_GE(val1, val2) \
- while (false) NDEBUG_EAT_STREAM_PARAMETERS
+ while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_GT(val1, val2) \
- while (false) NDEBUG_EAT_STREAM_PARAMETERS
+ while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_STREQ(str1, str2) \
- while (false) NDEBUG_EAT_STREAM_PARAMETERS
+ while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_STRCASEEQ(str1, str2) \
- while (false) NDEBUG_EAT_STREAM_PARAMETERS
+ while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_STRNE(str1, str2) \
- while (false) NDEBUG_EAT_STREAM_PARAMETERS
+ while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_STRCASENE(str1, str2) \
- while (false) NDEBUG_EAT_STREAM_PARAMETERS
+ while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS
#else
#ifndef NDEBUG