Recently (for example in Fedora 34), the C++ header files started to
include the system's <single_threaded.h>, and that include <features.h>
and assumes it is enough to define __BEGIN_DECLS. However, this macro
is actually defined in <sys/cdefs.h>, so we get many build errors like:

/usr/include/sys/single_threaded.h:24:1: error: ‘__BEGIN_DECLS’ does not name a 
type
   24 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~

The fix is to include <sys/cdefs.h> from our compatibility <features.h>.
This is what glibc does too.

Signed-off-by: Nadav Har'El <[email protected]>
---
 include/glibc-compat/features.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/glibc-compat/features.h b/include/glibc-compat/features.h
index 7f5c4ee7..cccae9c5 100644
--- a/include/glibc-compat/features.h
+++ b/include/glibc-compat/features.h
@@ -10,6 +10,11 @@
 
 #include_next <features.h>
 
+/* Recently, some system header files started to rely on <features.h>
+ * already including <sys/cdefs.h>. So we need to do it.
+ */
+#include <sys/cdefs.h>
+
 #define hidden __attribute__((__visibility__("hidden")))
 
 #define __GNU_LIBRARY__ 6
-- 
2.31.1

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20210614062057.1998552-2-nyh%40scylladb.com.

Reply via email to