Skip to content

Commit d2455b9

Browse files
cyyeverpytorchmergebot
authored andcommitted
Use cpython declaration of _PyWeakref_ClearRef (pytorch#136300)
To avoid the DLL inconsistency warning by MSVC: ``` torch/csrc/utils/python_compat.h(38): warning C4273: '_PyWeakref_ClearRef': inconsistent dll linkage ``` Pull Request resolved: pytorch#136300 Approved by: https://github.com/Skylion007
1 parent 7f9c064 commit d2455b9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

torch/csrc/utils/python_compat.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ PyCode_GetNFreevars(PyCodeObject* code) {
3535
}
3636

3737
// Provided by CPython but getting the header for them is very hard
38+
#if IS_PYTHON_3_11_PLUS
39+
PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference* self);
40+
#else
3841
extern void _PyWeakref_ClearRef(PyWeakReference* self);
42+
#endif
3943

4044
#ifdef __cplusplus
4145
}

0 commit comments

Comments
 (0)