On 14/2/26 07:10, Pierrick Bouvier wrote:
This make sure we can include all possible headers without breaking
build for environments missing them. It fixes compilation on openbsd.

We don't want to pollute configure script, as it's really a special case
here to make sure we don't have a compilation regression with
qemu-plugins header.

Signed-off-by: Pierrick Bouvier <[email protected]>
---
  contrib/plugins/cpp.cpp | 261 +++++++++++++++++++++++++++++++++++++++-
  1 file changed, 259 insertions(+), 2 deletions(-)

diff --git a/contrib/plugins/cpp.cpp b/contrib/plugins/cpp.cpp
index 1ff54896d97..0673c4f074d 100644
--- a/contrib/plugins/cpp.cpp
+++ b/contrib/plugins/cpp.cpp
@@ -6,103 +6,360 @@
#include <qemu-plugin.h> -/* https://en.cppreference.com/w/cpp/headers.html */
+/*
+ * We include all C++ standard headers (without deprecated ones),
+ * taken from: https://en.cppreference.com/w/cpp/headers.html
+ *
+ * To update, copy page text, and then:
+ * grep '^<' |
+ * sort -u |
+ * grep -v strstream |
+ * grep -v codecvt |
+ * sed -e 's/\(.*\)/#if __has_include(\1)\n#include \1\n#endif/'
+ */
+
+#if __has_include(<algorithm>)
  #include <algorithm>
+#endif

Should we test __has_include is defined, as the GCC documentation
recommends?

  [...] the recommended use of the operators is as follows:

  #if defined __has_include
  #  if __has_include (<stdatomic.h>)
  #    include <stdatomic.h>
  #  endif
  #endif

https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html

Reply via email to