diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-05-24 13:16:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-24 13:16:08 (GMT) |
commit | b3a9843cd19039808a812ca11206881c94c64e3b (patch) | |
tree | ee801eaed47ba95e99592e26d8c5b041b992bcf7 /Include | |
parent | b4bdecd0fc9112b60a81fec171bc78bc13f2f59c (diff) | |
download | cpython-b3a9843cd19039808a812ca11206881c94c64e3b.zip cpython-b3a9843cd19039808a812ca11206881c94c64e3b.tar.gz cpython-b3a9843cd19039808a812ca11206881c94c64e3b.tar.bz2 |
Support Py_UNUSED() on clang (GH-13544)
Diffstat (limited to 'Include')
-rw-r--r-- | Include/pymacro.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Include/pymacro.h b/Include/pymacro.h index 546f9c6..1890619 100644 --- a/Include/pymacro.h +++ b/Include/pymacro.h @@ -89,10 +89,15 @@ /* Check if pointer "p" is aligned to "a"-bytes boundary. */ #define _Py_IS_ALIGNED(p, a) (!((uintptr_t)(p) & (uintptr_t)((a) - 1))) -#ifdef __GNUC__ -#define Py_UNUSED(name) _unused_ ## name __attribute__((unused)) +/* Use this for unused arguments in a function definition to silence compiler + * warnings. Example: + * + * int func(int a, int Py_UNUSED(b)) { return a; } + */ +#if defined(__GNUC__) || defined(__clang__) +# define Py_UNUSED(name) _unused_ ## name __attribute__((unused)) #else -#define Py_UNUSED(name) _unused_ ## name +# define Py_UNUSED(name) _unused_ ## name #endif #define Py_UNREACHABLE() abort() |