From c97b65f7f65d3ee8d3981b52f1be94ecae9a5161 Mon Sep 17 00:00:00 2001 From: HEYAHONG <2229388563@qq.com> Date: Fri, 10 Jan 2025 15:24:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Windows=E4=B8=8B=E7=BC=96?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hbox/hdefaults.h | 17 +++++++++++++++++ hbox/hdefaults/hdefaults_os_windows.h | 1 + hcppbox/HCPPBox.h | 1 + hcppbox/HCPPGui.h | 1 + hcppbox/HCPPSocket.h | 2 +- test/SConstruct | 4 +--- 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/hbox/hdefaults.h b/hbox/hdefaults.h index 313ca30..b078c1b 100644 --- a/hbox/hdefaults.h +++ b/hbox/hdefaults.h @@ -32,6 +32,23 @@ extern "C" #endif // WIN32 #endif // __CYGWIN__ +//提高windows下的兼容性 +#ifdef _WIN32 +#ifndef WIN32 +#define WIN32 1 +#endif // WIN32 +#endif // _WIN32 +#ifdef __WIN32 +#ifndef WIN32 +#define WIN32 1 +#endif // WIN32 +#endif // __WIN32 +#ifdef __WIN32__ +#ifndef WIN32 +#define WIN32 1 +#endif // WIN32 +#endif // __WIN32__ + //定义操作系统 #ifdef __RTTHREAD__ #include "hdefaults/hdefaults_os_rtthread.h" diff --git a/hbox/hdefaults/hdefaults_os_windows.h b/hbox/hdefaults/hdefaults_os_windows.h index 96a7e4e..c9ecdc0 100644 --- a/hbox/hdefaults/hdefaults_os_windows.h +++ b/hbox/hdefaults/hdefaults_os_windows.h @@ -9,6 +9,7 @@ #ifndef __HDEFAULTS_OS_WINDOWS_H__ #define __HDEFAULTS_OS_WINDOWS_H__ #include "hdefaults_common.h" +#include "winsock2.h" #include "windows.h" diff --git a/hcppbox/HCPPBox.h b/hcppbox/HCPPBox.h index 176429f..41746d6 100644 --- a/hcppbox/HCPPBox.h +++ b/hcppbox/HCPPBox.h @@ -9,6 +9,7 @@ #ifndef HCPPBOX_H_INCLUDED #define HCPPBOX_H_INCLUDED +#include "hbox.h" #include "HCPPObject.h" #include "HCPPObjectPool.h" #include "HCPPThread.h" diff --git a/hcppbox/HCPPGui.h b/hcppbox/HCPPGui.h index 1dc0312..1eaf2ef 100644 --- a/hcppbox/HCPPGui.h +++ b/hcppbox/HCPPGui.h @@ -8,6 +8,7 @@ **************************************************************/ #ifndef __HCPPGUI_H__ #define __HCPPGUI_H__ +#include "hbox.h" #ifdef __cplusplus extern "C" diff --git a/hcppbox/HCPPSocket.h b/hcppbox/HCPPSocket.h index e029196..3b7e8b4 100644 --- a/hcppbox/HCPPSocket.h +++ b/hcppbox/HCPPSocket.h @@ -8,7 +8,7 @@ **************************************************************/ #ifndef __HCPPSOCKET_H__ #define __HCPPSOCKET_H__ - +#include "hbox.h" #if defined(__unix__) || defined(__linux__) #ifndef HCPPSOCKET_HAVE_SOCKET #define HCPPSOCKET_HAVE_SOCKET 1 diff --git a/test/SConstruct b/test/SConstruct index 7fdda30..6281ba9 100644 --- a/test/SConstruct +++ b/test/SConstruct @@ -19,10 +19,8 @@ print("Tools={}".format(env["TOOLS"])) if "msvc" in env["TOOLS"]: env.AppendUnique(CFLAGS='/utf-8') env.AppendUnique(CFLAGS='/std:clatest') - env.AppendUnique(CFLAGS='/DWIN32=1') - env.AppendUnique(CXXFLAGS='/utf-8') env.AppendUnique(CXXFLAGS='/std:c++latest') - env.AppendUnique(CXXFLAGS='/DWIN32=1') + env.AppendUnique(CXXFLAGS='/utf-8') env.AppendUnique(LIBS=['kernel32.lib','user32.lib','gdi32.lib','winspool.lib','shell32.lib','ole32.lib','oleaut32.lib','uuid.lib','comdlg32.lib','advapi32.lib']) #gcc设置