From 46b86892de7cc81cf5a1592067771a7e6b604016 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Fri, 22 Mar 2013 18:47:38 +0100 Subject: [PATCH] Add __PRAGMA_WARNING for inserting warnings. --- libc/include/features.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libc/include/features.h b/libc/include/features.h index 7871b183..16bea8b2 100644 --- a/libc/include/features.h +++ b/libc/include/features.h @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. This file is part of the Sortix C Library. @@ -25,6 +25,21 @@ #ifndef _FEATURES_H #define _FEATURES_H 1 +/* Support macro to ease testing the compiler version. */ +#define __GCC_PREREQ(gcc_major, gcc_minor) \ + (((gcc_major) == __GNUC__ && (gcc_minor) >= __GNUC_MINOR__) || \ + ((gcc_major) < __GNUC__)) + +/* Preprocessor trick to turn anything into a string. */ +#define __STRINGIFY(x) #x + +/* Issue warning when this is used, except in defines, where the warning is + inserted whenever the macro is expanded. This can be used to deprecated + macros - and it happens on preprocessor level - so it shouldn't change any + semantics of any code that uses such a macro. The argument msg should be a + string that contains the warning. */ +#define __PRAGMA_WARNING(msg) _Pragma(__STRINGIFY(GCC warning msg)) + /* C++ needs to know that types and declarations are C, not C++. */ #ifdef __cplusplus #define __BEGIN_DECLS extern "C" {