Fix -Wexpansion-to-defined warning from Clang 3.9
authorKevin Funk <kfunk@kde.org>
Mon, 6 Mar 2017 14:35:10 +0000 (15:35 +0100)
committerKevin Funk <kfunk@kde.org>
Mon, 6 Mar 2017 14:35:10 +0000 (15:35 +0100)
Fixed:

```
/home/kfunk/devel/src/kf5/heaptrack/tests/manual/test.cpp:65:5: warning:
macro expansion producing 'defined' has undefined behavior
[-Wexpansion-to-defined]
  #if HAVE_ALIGNED_ALLOC
      ^
/home/kfunk/devel/src/kf5/heaptrack/tests/manual/test.cpp:4:28: note:
expanded from macro 'HAVE_ALIGNED_ALLOC'
  #define HAVE_ALIGNED_ALLOC defined(_ISOC11_SOURCE)
```

src/track/heaptrack_preload.cpp
tests/manual/test.cpp

index b106bcd..149b194 100644 (file)
 
 using namespace std;
 
-#define HAVE_ALIGNED_ALLOC defined(_ISOC11_SOURCE)
-#define HAVE_CFREE (defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || defined(__USE_MISC))
+#if defined(_ISOC11_SOURCE)
+#  define HAVE_ALIGNED_ALLOC 1
+#else
+#  define HAVE_ALIGNED_ALLOC 0
+#endif
+#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || defined(__USE_MISC)
+#  define HAVE_CFREE 1
+#else
+#  define HAVE_CFREE 0
+#endif
 
 namespace {
 
index e3f1870..05d967c 100644 (file)
@@ -1,7 +1,11 @@
 #include <cstdio>
 #include <cstdlib>
 
-#define HAVE_ALIGNED_ALLOC defined(_ISOC11_SOURCE)
+#if defined(_ISOC11_SOURCE)
+#  define HAVE_ALIGNED_ALLOC 1
+#else
+#  define HAVE_ALIGNED_ALLOC 0
+#endif
 
 struct Foo
 {