Guest User

Untitled

a guest
May 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. // in some file:
  2. #define HAS_GNU (defined(__GNUC__) && !defined(__clang__))
  3.  
  4. // possibly in another file:
  5. #if defined(__clang__) || HAS_GNU
  6. /* ... */
  7. #endif
  8.  
  9. test.cc:5:27: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
  10. #if defined(__clang__) || HAS_GNU
  11. ^
  12. test.cc:3:18: note: expanded from macro 'HAS_GNU'
  13. #define HAS_GNU (defined(__GNUC__) && !defined(__clang__))
  14. ^
  15. test.cc:5:27: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
  16. test.cc:3:40: note: expanded from macro 'HAS_GNU'
  17. #define HAS_GNU (defined(__GNUC__) && !defined(__clang__))
  18.  
  19. #if defined(__GNUC__) && !defined(__clang__)
  20. #define HAS_GNU 1
  21. #else
  22. #define HAS_GNU 0
  23. #endif
  24.  
  25. #if defined(__GNUC__) && !defined(__clang__)
  26. #define HAS_GNU
  27. #endif
  28.  
  29. #if defined(__clang__) || defined(HAS_GNU)
  30.  
  31. #pragma clang diagnostic push
  32. #pragma clang diagnostic ignored "-Wexpansion-to-defined"
  33. #import <pop/POP.h>
  34. #pragma clang diagnostic pop
Add Comment
Please, Sign In to add comment