Skip to content

Commit 4bcff7f

Browse files
committed
address review
1 parent efa7bdc commit 4bcff7f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Include/methodobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ typedef PyObject *(*PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *,
3333
typedef PyCFunctionFast _PyCFunctionFast;
3434
typedef PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords;
3535

36-
// Cast an function to the PyCFunction type to use it with PyMethodDef.
36+
// Cast a function to the PyCFunction type to use it with PyMethodDef.
3737
//
3838
// This macro can be used to prevent compiler warnings if the first parameter
3939
// uses a different pointer type than PyObject* (ex: METH_VARARGS and METH_O

Include/pyport.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
#endif
3636
// Macro to use the more powerful/dangerous C-style cast even in C++.
3737
#define _Py_CAST(type, expr) ((type)(expr))
38+
// Cast a function to another function type T.
39+
//
40+
// The macro first casts the function to the "void func(void)" type
41+
// to prevent compiler warnings.
42+
//
43+
// Note that using this cast only prevents the compiler from emitting
44+
// warnings, but does not prevent an undefined behavior at runtime if
45+
// the original function signature is not respected.
3846
#define _Py_FUNC_CAST(T, func) _Py_CAST(T, _Py_CAST(void(*)(void), (func)))
3947

4048
// Static inline functions should use _Py_NULL rather than using directly NULL

0 commit comments

Comments
 (0)