Sfoglia il codice sorgente

Moved all windows specific #define/#undef to WinHeaders.h

Dexter89 12 anni fa
parent
commit
11844a738f

+ 1 - 0
engine/CMakeLists.txt

@@ -570,6 +570,7 @@ if (WINDOWS)
 	)
 
 	list (APPEND OS_HEADERS
+		os/win/WinHeaders.h
 		os/win/OsFile.h
 		os/win/OsThread.h
 		os/win/OsSocket.h

+ 0 - 4
engine/ConsoleServer.cpp

@@ -36,10 +36,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Filesystem.h"
 #include "MathUtils.h"
 
-#ifdef WINDOWS
-#undef NO_ERROR
-#endif
-
 namespace crown
 {
 

+ 0 - 5
engine/core/Log.cpp

@@ -28,11 +28,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Device.h"
 #include "ConsoleServer.h"
 
-#ifdef WINDOWS
-#undef ERROR
-#define __va_copy(dest, src) (dest = src)
-#endif
-
 namespace crown
 {
 

+ 0 - 4
engine/core/Log.h

@@ -31,10 +31,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Types.h"
 #include "Macros.h"
 
-#ifdef WINDOWS
-#undef ERROR
-#endif
-
 namespace crown
 {
 

+ 0 - 2
engine/core/containers/RBTree.h

@@ -25,8 +25,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #pragma once
-#undef min
-#undef max
 
 #include <cstdlib>
 

+ 0 - 5
engine/core/math/Frustum.h

@@ -32,11 +32,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Plane.h"
 #include "Intersection.h"
 
-#ifdef WINDOWS
-#undef NEAR
-#undef FAR
-#endif
-
 namespace crown
 {
 

+ 0 - 3
engine/core/math/MathUtils.h

@@ -26,9 +26,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#undef min
-#undef max
-
 #include <math.h>
 
 #include "Assert.h"

+ 0 - 2
engine/core/settings/FloatSetting.h

@@ -25,8 +25,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #pragma once
-#undef min
-#undef max
 
 #include "Types.h"
 

+ 0 - 2
engine/core/settings/IntSetting.h

@@ -25,8 +25,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #pragma once
-#undef min
-#undef max
 
 #include "Types.h"
 

+ 0 - 7
engine/os/OS.h

@@ -43,13 +43,6 @@ namespace crown
 #elif defined(WINDOWS)
 	const size_t	MAX_PATH_LENGTH = 1024;
 	const char		PATH_SEPARATOR = '\\';
-
-	#define snprintf _snprintf
-
-	#undef MK_SHIFT
-	#undef MK_ALT
-	#undef ERROR
-
 #elif defined(ANDROID)
 	const size_t	MAX_PATH_LENGTH = 1024;
 	const char		PATH_SEPARATOR = '/';

+ 1 - 1
engine/os/win/AtomicInt.h

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "windows.h"
+#include "WinHeaders.h"
 
 namespace crown
 {

+ 1 - 5
engine/os/win/Cond.h

@@ -26,11 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#include <windows.h>
+#include "WinHeaders.h"
 #include "Types.h"
 #include "Mutex.h"
 #include "OS.h"

+ 1 - 5
engine/os/win/Mutex.h

@@ -26,11 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#include <windows.h>
+#include "WinHeaders.h"
 #include "Types.h"
 #include "OS.h"
 

+ 1 - 5
engine/os/win/OsFile.h

@@ -26,12 +26,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
 #include <cstdio>
-#include <windows.h>
+#include "WinHeaders.h"
 #include "Types.h"
 #include "File.h"
 

+ 6 - 3
engine/os/win/OsSocket.h

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-//Undefined in Frustum.h, but winsock2 ecc need it.
+//Undefined in WinHeaders.h, but winsock2 ecc need it.
 #ifndef NEAR
 #define NEAR
 #endif
@@ -35,7 +35,11 @@ OTHER DEALINGS IN THE SOFTWARE.
 #endif
 
 #include <winsock2.h>
-#include <windows.h>
+#include "WinHeaders.h"
+
+//Re-undef NEAR and FAR after use
+#undef NEAR
+#undef FAR
 
 #include "NetAddress.h"
 #include "Assert.h"
@@ -43,7 +47,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "OS.h"
 
 #pragma comment(lib, "Ws2_32.lib")
-#undef NO_ERROR
 
 namespace crown
 {

+ 1 - 5
engine/os/win/OsThread.h

@@ -26,11 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#include <windows.h>
+#include "WinHeaders.h"
 #include <process.h>
 #include <WinBase.h>
 

+ 1 - 5
engine/os/win/OsWindow.h

@@ -26,11 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#include <windows.h>
+#include "WinHeaders.h"
 
 #include "Types.h"
 #include "Macros.h"

+ 1 - 5
engine/os/win/Semaphore.h

@@ -26,11 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#include <windows.h>
+#include "WinHeaders.h"
 #include <limits.h>
 
 #include "Assert.h"

+ 47 - 0
engine/os/win/WinHeaders.h

@@ -0,0 +1,47 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#pragma once
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+
+#include "Windows.h"
+
+#undef NEAR
+#undef FAR
+#undef near
+#undef far
+#undef NO_ERROR
+#undef ERROR
+#undef MK_SHIFT
+#undef MK_ALT
+#undef min
+#undef max
+
+#define snprintf _snprintf
+#define __va_copy(dest, src) (dest = src)

+ 1 - 1
engine/os/win/WinOS.cpp

@@ -24,7 +24,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include <windows.h>
+#include "WinHeaders.h"
 #include <cstdio>
 #include <cstdarg>
 #include "StringUtils.h"

+ 0 - 4
engine/os/win/main.cpp

@@ -24,10 +24,6 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
 #include <windowsx.h>
 
 #define WM_USER_SET_WINDOW_SIZE     (WM_USER+0)

+ 1 - 1
engine/renderers/backend/gl/wgl/wglext.h

@@ -40,7 +40,7 @@ extern "C" {
 /* Function declaration macros - to move into glplatform.h */
 #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
 #define WIN32_LEAN_AND_MEAN 1
-#include <windows.h>
+#include "WinHeaders.h"
 #endif
 
 #ifndef APIENTRY