Commit b3a9843c authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

Support Py_UNUSED() on clang (GH-13544)

parent b4bdecd0
...@@ -156,7 +156,7 @@ complete listing. ...@@ -156,7 +156,7 @@ complete listing.
.. c:macro:: Py_UNUSED(arg) .. c:macro:: Py_UNUSED(arg)
Use this for unused arguments in a function definition to silence compiler Use this for unused arguments in a function definition to silence compiler
warnings, e.g. ``PyObject* func(PyObject *Py_UNUSED(ignored))``. warnings. Example: ``int func(int a, int Py_UNUSED(b)) { return a; }``.
.. versionadded:: 3.4 .. versionadded:: 3.4
......
...@@ -89,10 +89,15 @@ ...@@ -89,10 +89,15 @@
/* Check if pointer "p" is aligned to "a"-bytes boundary. */ /* Check if pointer "p" is aligned to "a"-bytes boundary. */
#define _Py_IS_ALIGNED(p, a) (!((uintptr_t)(p) & (uintptr_t)((a) - 1))) #define _Py_IS_ALIGNED(p, a) (!((uintptr_t)(p) & (uintptr_t)((a) - 1)))
#ifdef __GNUC__ /* Use this for unused arguments in a function definition to silence compiler
#define Py_UNUSED(name) _unused_ ## name __attribute__((unused)) * 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 #else
#define Py_UNUSED(name) _unused_ ## name # define Py_UNUSED(name) _unused_ ## name
#endif #endif
#define Py_UNREACHABLE() abort() #define Py_UNREACHABLE() abort()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment