Skip to content

Commit 3e0bde9

Browse files
committed
Fix compatibility with Visual Studio 2013
Visual C++ 2008 fails with a compiler error on "inline" keyword when building a C file.
1 parent 015de3f commit 3e0bde9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pythoncapi_compat.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ extern "C" {
2222
#include "frameobject.h" // PyFrameObject, PyFrame_GetBack()
2323

2424

25+
// Compatibility with Visual Studio 2013 and older which don't support
26+
// the inline keyword in C (only in C++): use __inline instead.
27+
#if (defined(_MSC_VER) && _MSC_VER < 1900 \
28+
&& !defined(__cplusplus) && !defined(inline))
29+
# define inline __inline
30+
# define PYTHONCAPI_COMPAT_MSC_INLINE
31+
// These two macros are undefined at the end of this file
32+
#endif
33+
34+
2535
// Cast argument to PyObject* type.
2636
#ifndef _PyObject_CAST
2737
# define _PyObject_CAST(op) ((PyObject*)(op))
@@ -286,6 +296,11 @@ _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) {
286296
#endif
287297

288298

299+
#ifdef PYTHONCAPI_COMPAT_MSC_INLINE
300+
# undef inline
301+
# undef PYTHONCAPI_COMPAT_MSC_INLINE
302+
#endif
303+
289304
#ifdef __cplusplus
290305
}
291306
#endif

0 commit comments

Comments
 (0)