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
This commit is contained in:
Martin Kaiser 2013-02-21 18:40:48 +00:00
parent 38a73a32f3
commit b057717767
1 changed files with 34 additions and 0 deletions

View File

@ -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 <gcrypt.h>
#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 <gcrypt.h>
#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 <gcrypt.h>
#pragma GCC diagnostic pop
#endif /* _GCC_VERSION */
#endif /* HAVE_LIBGRYPT */
#endif /* __WSGCRYPT_H__ */