Don't use 'defined' in macro expansion.
A careful reading of the preprocessor specification indicates that
any use of the 'defined' operator outside the form of 'defined X' or
'defined ( X )' directly in the constant expression of a '#if' or
'#elif' may cause undefined behavior.
In particular, msvc is very unpredictable. The 'defined X' and
'defined ( X )' forms behave differently when created from marco
expansion, with 'defined ( X )' generally evaluating to '0L'. The
'defined X' form generally behaves more the way one would expect,
but still has a number of quirks which should simply be considered
undefined behavior.
BUG=chromium:419245
Review URL: https://codereview.chromium.org/657183002
diff --git a/include/core/SkFloatingPoint.h b/include/core/SkFloatingPoint.h
index 2df8f9b..f85c456 100644
--- a/include/core/SkFloatingPoint.h
+++ b/include/core/SkFloatingPoint.h
@@ -32,8 +32,12 @@
static inline float sk_float_copysign(float x, float y) {
// c++11 contains a 'float copysign(float, float)' function in <cmath>.
// clang-cl reports __cplusplus for clang, not the __cplusplus vc++ version _MSC_VER would report.
-#define SK_BUILD_WITH_CLANG_CL (defined(_MSC_VER) && defined(__clang__))
-#if (!SK_BUILD_WITH_CLANG_CL && __cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
+#if (defined(_MSC_VER) && defined(__clang__))
+# define SK_BUILD_WITH_CLANG_CL 1
+#else
+# define SK_BUILD_WITH_CLANG_CL 0
+#endif
+#if (!SK_BUILD_WITH_CLANG_CL && __cplusplus >= 201103L) || (_MSC_VER >= 1800)
return copysign(x, y);
// Posix has demanded 'float copysignf(float, float)' (from C99) since Issue 6.
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h
index ec17b65..2d6ab44 100644
--- a/include/core/SkPostConfig.h
+++ b/include/core/SkPostConfig.h
@@ -126,10 +126,10 @@
* Defaults to 1 in DEBUG and 0 in RELEASE.
*/
#ifndef SK_ENABLE_INST_COUNT
-# ifdef SK_DEBUG
// Only enabled for static builds, because instance counting relies on static
// variables in functions defined in header files.
-# define SK_ENABLE_INST_COUNT !defined(SKIA_DLL)
+# if defined(SK_DEBUG) && !defined(SKIA_DLL)
+# define SK_ENABLE_INST_COUNT 1
# else
# define SK_ENABLE_INST_COUNT 0
# endif