Skip to content

Commit 7439a59

Browse files
More Windows compatibility.
1 parent b25409f commit 7439a59

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

include/pybind11/detail/non_limited_api.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
#if !defined(__APPLE__) && !defined(_WIN32)
99
#include <dlfcn.h> // For `dlopen` and friends.
1010
#endif
11+
#ifdef _WIN32
12+
#define WIN32_LEAN_AND_MEAN
13+
#define NOMINMAX 1
14+
#include <windows.h>
15+
#endif
1116

1217
#ifdef Py_LIMITED_API
1318
typedef struct _heaptypeobject PyHeapTypeObject;
@@ -189,7 +194,7 @@ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
189194
HMODULE module_handle = NULL; \
190195
if (!GetModuleHandleExW( \
191196
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, \
192-
(LPCTSTR)PYBIND11_CONCAT(PyInit_, module_), \
197+
(LPCWSTR)PYBIND11_CONCAT(PyInit_, module_), \
193198
&module_handle \
194199
)) \
195200
{ \

source/non_limited_api/non_limited_api_stubs.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
#include "pybind11/pybind11.h"
44

55
#ifdef _WIN32
6-
#define WIN32_LEAN_AND_MEAN
7-
#define NOMINMAX 1
8-
#include <windows.h>
96
#define PYBIND11_NONLIMITEDAPI_DLOPEN(dir, file) LoadLibraryW((dir + std::wstring(file.begin(), file.end()) + L".dll").c_str())
107
#define PYBIND11_NONLIMITEDAPI_DLOPEN_ERROR std::to_string(GetLastError()).c_str()
118
#else

0 commit comments

Comments
 (0)