Przeglądaj źródła

windows.h is evil

Daniele Bartolini 11 lat temu
rodzic
commit
5cb238db37

+ 7 - 5
engine/core/filesystem/os_file.h

@@ -26,15 +26,17 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include <cstdio>
+#include "file.h" // FileOpenMode
 #include "types.h"
 #include "assert.h"
-#include "config.h"
 #include "macros.h"
-#include "file.h" // FileOpenMode
+#include "config.h"
 
-#if CROWN_PLATFORM_WINDOWS
+#if CROWN_PLATFORM_POSIX
+	#include <cstdio>
+#elif CROWN_PLATFORM_WINDOWS
 	#include "tchar.h"
+	#include "win_headers.h"
 #endif
 
 namespace crown
@@ -147,7 +149,7 @@ public:
 		return fwrite(data, 1, size, _file);
 #elif CROWN_PLATFORM_WINDOWS
 		DWORD bytes_written;
-		bool write = WriteFile(_file, data, size, &bytes_written, NULL);
+		WriteFile(_file, data, size, &bytes_written, NULL);
 		CE_ASSERT(size == bytes_written, "Cannot read from file\n");
 		return size;
 #endif

+ 2 - 5
engine/core/network/socket.h

@@ -40,7 +40,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 	#include <unistd.h>
 	#include <errno.h>
 #elif CROWN_PLATFORM_WINDOWS
-//Undefined in WinHeaders.h, but winsock2 ecc need it.
+	//Undefined in WinHeaders.h, but winsock2 ecc need it.
 	#ifndef NEAR
 	#define NEAR
 	#endif
@@ -48,10 +48,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 	#define FAR
 	#endif
 	#include <winsock2.h>
-	#include <win_headers.h>
-	//Re-undef NEAR and FAR after use
-	#undef NEAR
-	#undef FAR
+	#include "win_headers.h"
 	#pragma comment(lib, "Ws2_32.lib")
 #endif
 

+ 1 - 4
engine/core/thread/mutex.h

@@ -34,10 +34,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #if CROWN_PLATFORM_POSIX
 	#include <pthread.h>
 #elif CROWN_PLATFORM_WINDOWS
-	#ifndef WIN32_LEAN_AND_MEAN
-	#define WIN32_LEAN_AND_MEAN 1
-	#endif
-	#include <windows.h>
+	#include "win_headers.h"
 #endif
 
 namespace crown