Page MenuHome GnuPG

Using GCRY_THREAD_OPTION_PTHREAD_IMPL in a file compiled with Clang generates deprecation warning
Open, LowPublic

Description

If I compile my program containing:

#include <gcrypt.h>
GCRY_THREAD_OPTION_PTHREAD_IMPL;

with Clang-10 or Clang-11, then I get a warning:

test.c:3:1: warning: 'gcry_thread_cbs' is deprecated [-Wdeprecated-declarations]
GCRY_THREAD_OPTION_PTHREAD_IMPL;
^
/usr/include/gcrypt.h:225:17: note: expanded from macro 'GCRY_THREAD_OPTION_PTHREAD_IMPL'
  static struct gcry_thread_cbs gcry_threads_pthread = {                \
                ^
/usr/include/gcrypt.h:218:3: note: 'gcry_thread_cbs' has been explicitly marked deprecated here
} _GCRY_ATTR_INTERNAL;
  ^
/usr/include/gcrypt.h:130:29: note: expanded from macro '_GCRY_ATTR_INTERNAL'
#define _GCRY_ATTR_INTERNAL     _GCRY_GCC_ATTR_DEPRECATED
                                ^
/usr/include/gcrypt.h:90:51: note: expanded from macro '_GCRY_GCC_ATTR_DEPRECATED'
#define _GCRY_GCC_ATTR_DEPRECATED __attribute__ ((__deprecated__))
                                                  ^
test.c:3:1: warning: unused variable 'gcry_threads_pthread' [-Wunused-variable]
GCRY_THREAD_OPTION_PTHREAD_IMPL;
^
/usr/include/gcrypt.h:225:33: note: expanded from macro 'GCRY_THREAD_OPTION_PTHREAD_IMPL'
  static struct gcry_thread_cbs gcry_threads_pthread = {                \
                                ^
2 warnings generated.

This appears to be because gcrypt.h.in marks gcry_thread_cbs as deprecated in an attempt to restrict its use to only the macros. GCC doesn't warn in this case, but Clang does. This causes problems when compiling with -Werror.

Others seem to have noticed this too.

The attached patch isn't very satisfying, but it does solve the problem for me.

Details

Version
1.8.4, 1.8.7 (but appears to also be present on master)

Event Timeline

werner added a subscriber: werner.

Yet another identify theft scam committed by clang.

But, yes, I can understand your problem and I will see what we can do about it.