From 3b350317465066a12347e26ddb858dcadadad7c3 Mon Sep 17 00:00:00 2001 From: Virgile Prevosto <virgile.prevosto@m4x.org> Date: Fri, 22 Feb 2019 10:19:52 +0100 Subject: [PATCH] [libc] avoid clang complains on unknown attributes when parsing libc especially useful for frama-clang, but could come handy should a user want to use clang as C pre-processor --- share/libc/features.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/share/libc/features.h b/share/libc/features.h index 08d5c8de3db..5c54040b141 100644 --- a/share/libc/features.h +++ b/share/libc/features.h @@ -34,12 +34,27 @@ #define __POP_FC_STDLIB #endif +#ifdef __clang__ +# define __CLANG_IGNORE_ATTRS_PUSH__ \ +_Pragma("clang diagnostic push") \ +_Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") +# define __CLANG_IGNORE_ATTRS_POP__ \ +_Pragma("clang diagnostic pop") +#else +# define __CLANG_IGNORE_ATTRS_PUSH__ +# define __CLANG_IGNORE_ATTRS_POP__ +#endif + #ifdef __cplusplus -# define __BEGIN_DECLS extern "C" { -# define __END_DECLS } +# define __BEGIN_DECLS \ +extern "C" { \ + __CLANG_IGNORE_ATTRS_PUSH__ +# define __END_DECLS \ +__CLANG_IGNORE_ATTRS_POP__ \ +} #else -# define __BEGIN_DECLS -# define __END_DECLS +# define __BEGIN_DECLS __CLANG_IGNORE_ATTRS_PUSH__ +# define __END_DECLS __CLANG_IGNORE_ATTRS_POP__ #endif #undef __LEAF -- GitLab