gcc7-build-fix.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. From 9e2c32390c5c253aade3bb703e51841748d2c37e Mon Sep 17 00:00:00 2001
  2. From: Jonathan Wakely <jwakely@redhat.com>
  3. Date: Sat, 28 Jan 2017 01:26:00 +0000
  4. Subject: [PATCH] Remove abs(float) function that clashes with std::abs(float)
  5. Depending on which C++ standard library headers have been included there
  6. might an abs(float) function already declared in the global namespace,
  7. so the definition in this file conflicts with it. This cause a build
  8. failure with GCC 7, which conforms more closely to the C++ standard with
  9. respect to overloads of abs.
  10. Including <cmath> and adding a using-declaration for std::abs ensures
  11. that the standard std::abs(float) function is available. This solution
  12. should be portable to all compilers.
  13. ---
  14. handler.cc | 4 ++--
  15. 1 file changed, 2 insertions(+), 2 deletions(-)
  16. diff --git a/handler.cc b/handler.cc
  17. index 8830ea2..685b1ff 100644
  18. --- a/handler.cc
  19. +++ b/handler.cc
  20. @@ -23,6 +23,8 @@
  21. #include <X11/extensions/XTest.h>
  22. #include <X11/XKBlib.h>
  23. #include <X11/Xproto.h>
  24. +#include <cmath> // std::abs(float)
  25. +using std::abs;
  26. XState *xstate = nullptr;
  27. @@ -533,8 +535,6 @@ class WaitForPongHandler : public Handler, protected Timeout {
  28. virtual Grabber::State grab_mode() { return parent->grab_mode(); }
  29. };
  30. -static inline float abs(float x) { return x > 0 ? x : -x; }
  31. -
  32. class AbstractScrollHandler : public Handler {
  33. bool have_x, have_y;
  34. float last_x, last_y;