From b057717767c516123dbefb07ed5c736462a9d99d Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Thu, 21 Feb 2013 18:40:48 +0000 Subject: [PATCH] use pragma GCC diagnostic to work around gcrypt.h warnings distinguish between different gcc versions this should allow a clean build with libgcrypt 1.5.0 svn path=/trunk/; revision=47803 --- wsutil/wsgcrypt.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/wsutil/wsgcrypt.h b/wsutil/wsgcrypt.h index a92b5c977c..714ad78962 100644 --- a/wsutil/wsgcrypt.h +++ b/wsutil/wsgcrypt.h @@ -1,6 +1,9 @@ /* wsgcrypt.h * * Wrapper around libgcrypt's include file gcrypt.h. + * For libgcrypt 1.5.0, including gcrypt.h directly brings up lots of + * compiler warnings about deprecated definitions. + * Try to work around these warnings to ensure a clean build with -Werror. * * $Id$ * @@ -28,8 +31,39 @@ #ifdef HAVE_LIBGCRYPT +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +#define _GCC_VERSION (__GNUC__*100 + __GNUC_MINOR__*10) +#else +#define _GCC_VERSION 0 +#endif + +/* check the gcc version + pragma GCC diagnostic error/warning was introduced in gcc 4.2.0 + pragma GCC diagnostic push/pop was introduced in gcc 4.6.0 */ + +#if _GCC_VERSION<420 + +/* no gcc or gcc version<4.2.0: we can't do anything */ #include +#elif _GCC_VERSION<460 + +/* gcc version is between 4.2.0 and 4.6.0: + diagnostic warning/error is supported, diagnostic push/pop is not supported */ +#pragma GCC diagnostic warning "-Wdeprecated-declarations" +#include +#pragma GCC diagnostic error "-Wdeprecated-declarations" + +#else + +/* gcc version is >= 4.6.0: we can use push/pop */ +#pragma GCC diagnostic push +#pragma GCC diagnostic warning "-Wdeprecated-declarations" +#include +#pragma GCC diagnostic pop + +#endif /* _GCC_VERSION */ + #endif /* HAVE_LIBGRYPT */ #endif /* __WSGCRYPT_H__ */