使用libgcrypt v1.5.0进行编译器警告

时间:2012-05-11 17:55:12

标签: c libgcrypt

当我编译定义了GCRYPT_NO_DEPRECATED的示例程序时,我收到以下6个警告:

/usr/local/Cellar/libgcrypt/1.5.0/include/gcrypt.h:1336: warning: ‘gcry_ac_io_mode_t’ is deprecated
/usr/local/Cellar/libgcrypt/1.5.0/include/gcrypt.h:1337: warning: ‘gcry_ac_io_type_t’ is deprecated
/usr/local/Cellar/libgcrypt/1.5.0/include/gcrypt.h:1344: warning: ‘gcry_ac_data_read_cb_t’ is deprecated
/usr/local/Cellar/libgcrypt/1.5.0/include/gcrypt.h:1358: warning: ‘gcry_ac_data_write_cb_t’ is deprecated
/usr/local/Cellar/libgcrypt/1.5.0/include/gcrypt.h:1393: warning: ‘gcry_md_algo_t’ is deprecated
/usr/local/Cellar/libgcrypt/1.5.0/include/gcrypt.h:1401: warning: ‘gcry_md_algo_t’ is deprecated

手动定义_GCRYPT_IN_LIBGCRYPT可以解决6个警告,但手册的劝告相当严格:

  带有一个前置下划线的

名称前缀保留给内部   使用,不应该被应用程序使用。

那么如何在没有警告的情况下编译gcrypt标头?

1 个答案:

答案 0 :(得分:3)

gcrypt作者说,“这是一些编译器中的错误”

建议的解决方法是

#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
before the include, and
#pragma GCC diagnostic warning "-Wdeprecated-declarations"

http://lists.gnupg.org/pipermail/gcrypt-devel/2011-July/001829.html

http://lists.gnupg.org/pipermail/gcrypt-devel/2011-July/001830.html