From cf7dc098a3c719f6825e1d4e68729ff0ec7a37dd Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 2 Oct 2023 06:38:23 +0800 Subject: [PATCH] remove `windows.h` --- 3rd/box2d/CMakeLists.txt | 1 + include/pocketpy/export.h | 89 +++------------------------------------ src/pocketpy.cpp | 5 +++ src2/main.cpp | 2 + 4 files changed, 13 insertions(+), 84 deletions(-) diff --git a/3rd/box2d/CMakeLists.txt b/3rd/box2d/CMakeLists.txt index 16dd561c..6d491da3 100644 --- a/3rd/box2d/CMakeLists.txt +++ b/3rd/box2d/CMakeLists.txt @@ -15,6 +15,7 @@ aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src/rope BOX2D_SRC_3) aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src BOX2D_BINDINGS_SRC) set(CMAKE_CXX_FLAGS_RELEASE "-O2") +set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_library( box2d diff --git a/include/pocketpy/export.h b/include/pocketpy/export.h index 899e42d3..a879fc91 100644 --- a/include/pocketpy/export.h +++ b/include/pocketpy/export.h @@ -2,91 +2,12 @@ #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) //define something for Windows (32-bit and 64-bit, this part is common) - #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN - #endif - -/* - @raysan5: To avoid conflicting windows.h symbols with raylib, some flags are defined - WARNING: Those flags avoid inclusion of some Win32 headers that could be required - by user at some point and won't be included... -*/ - -/* If defined, the following flags inhibit definition of the indicated items.*/ -#define NOGDICAPMASKS // CC_*, LC_*, PC_*, CP_*, TC_*, RC_ -#define NOVIRTUALKEYCODES // VK_* -#define NOWINMESSAGES // WM_*, EM_*, LB_*, CB_* -#define NOWINSTYLES // WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_* -#define NOSYSMETRICS // SM_* -#define NOMENUS // MF_* -#define NOICONS // IDI_* -#define NOKEYSTATES // MK_* -#define NOSYSCOMMANDS // SC_* -#define NORASTEROPS // Binary and Tertiary raster ops -#define NOSHOWWINDOW // SW_* -#define OEMRESOURCE // OEM Resource values -#define NOATOM // Atom Manager routines -#define NOCLIPBOARD // Clipboard routines -#define NOCOLOR // Screen colors -#define NOCTLMGR // Control and Dialog routines -#define NODRAWTEXT // DrawText() and DT_* -#define NOGDI // All GDI defines and routines -#define NOKERNEL // All KERNEL defines and routines -#define NOUSER // All USER defines and routines -/*#define NONLS // All NLS defines and routines*/ -#define NOMB // MB_* and MessageBox() -#define NOMEMMGR // GMEM_*, LMEM_*, GHND, LHND, associated routines -#define NOMETAFILE // typedef METAFILEPICT -#ifndef NOMINMAX - #define NOMINMAX // Macros min(a,b) and max(a,b) -#endif -#define NOMSG // typedef MSG and associated routines -#define NOOPENFILE // OpenFile(), OemToAnsi, AnsiToOem, and OF_* -#define NOSCROLL // SB_* and scrolling routines -#define NOSERVICE // All Service Controller routines, SERVICE_ equates, etc. -#define NOSOUND // Sound driver routines -#define NOTEXTMETRIC // typedef TEXTMETRIC and associated routines -#define NOWH // SetWindowsHook and WH_* -#define NOWINOFFSETS // GWL_*, GCL_*, associated routines -#define NOCOMM // COMM driver routines -#define NOKANJI // Kanji support stuff. -#define NOHELP // Help engine interface. -#define NOPROFILER // Profiler interface. -#define NODEFERWINDOWPOS // DeferWindowPos routines -#define NOMCX // Modem Configuration Extensions -#define MMNOSOUND // Sound support - -/* Type required before windows.h inclusion */ -typedef struct tagMSG *LPMSG; - -#include - -/* Type required by some unused function... */ -typedef struct tagBITMAPINFOHEADER { - DWORD biSize; - LONG biWidth; - LONG biHeight; - WORD biPlanes; - WORD biBitCount; - DWORD biCompression; - DWORD biSizeImage; - LONG biXPelsPerMeter; - LONG biYPelsPerMeter; - DWORD biClrUsed; - DWORD biClrImportant; -} BITMAPINFOHEADER, *PBITMAPINFOHEADER; - -#include -#include -#include - -/* @raysan5: Some required types defined for MSVC/TinyC compiler */ -#if defined(_MSC_VER) || defined(__TINYC__) - #include -#endif - #define PK_EXPORT __declspec(dllexport) - #define PK_SUPPORT_DYLIB 1 + #ifdef PK_USE_DYLIB + #define PK_SUPPORT_DYLIB 1 + #else + #define PK_SUPPORT_DYLIB 0 + #endif #define PK_SYS_PLATFORM "win32" #elif __EMSCRIPTEN__ #include diff --git a/src/pocketpy.cpp b/src/pocketpy.cpp index df240db3..c42ead36 100644 --- a/src/pocketpy.cpp +++ b/src/pocketpy.cpp @@ -4,6 +4,11 @@ #include "box2dw.hpp" #endif +#if defined (_WIN32) && PK_SUPPORT_DYLIB == 1 +#define WIN32_LEAN_AND_MEAN +#include +#endif + namespace pkpy{ using dylib_entry_t = const char* (*)(void*, const char*); diff --git a/src2/main.cpp b/src2/main.cpp index 7802be15..171bfde3 100644 --- a/src2/main.cpp +++ b/src2/main.cpp @@ -11,6 +11,8 @@ #ifdef _WIN32 +#include + std::string pkpy_platform_getline(bool* eof){ HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); std::wstringstream wss;