瀏覽代碼

VCMIDirs update #6 fix

- Apple compilation fix
- Removed unnecessary macros
- Updated macros indent style
- Fixed 1. warning.
Karol 11 年之前
父節點
當前提交
37bd4790f7
共有 6 個文件被更改,包括 34 次插入47 次删除
  1. 32 42
      Global.h
  2. 1 1
      client/CMT.cpp
  3. 0 1
      client/CVideoHandler.h
  4. 0 1
      lib/CConsoleHandler.cpp
  5. 0 1
      lib/CGameInterface.cpp
  6. 1 1
      lib/VCMIDirs.cpp

+ 32 - 42
Global.h

@@ -56,49 +56,49 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 //	 and on: http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor
 //	 and on: http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor
 // TODO?: Should be moved to vstd\os_detect.h (and then included by Global.h)
 // TODO?: Should be moved to vstd\os_detect.h (and then included by Global.h)
 #ifdef _WIN16			// Defined for 16-bit environments
 #ifdef _WIN16			// Defined for 16-bit environments
-	#error "16-bit Windows isn't supported"
+#  error "16-bit Windows isn't supported"
 #elif defined(_WIN64)	// Defined for 64-bit environments
 #elif defined(_WIN64)	// Defined for 64-bit environments
-	#define VCMI_WINDOWS
-	#define VCMI_WINDOWS_64
+#  define VCMI_WINDOWS
+#  define VCMI_WINDOWS_64
 #elif defined(_WIN32)	// Defined for both 32-bit and 64-bit environments
 #elif defined(_WIN32)	// Defined for both 32-bit and 64-bit environments
-	#define VCMI_WINDOWS
-	#define VCMI_WINDOWS_32
+#  define VCMI_WINDOWS
+#  define VCMI_WINDOWS_32
 #elif defined(_WIN32_WCE)
 #elif defined(_WIN32_WCE)
-	#error "Windows CE isn't supported"
+#  error "Windows CE isn't supported"
 #elif defined(__linux__) || defined(__gnu_linux__) || defined(linux) || defined(__linux)
 #elif defined(__linux__) || defined(__gnu_linux__) || defined(linux) || defined(__linux)
-	#define VCMI_UNIX
-	#define VCMI_LINUX
-	#ifdef __ANDROID__
-		#define VCMI_ANDROID 
-	#endif
+#  define VCMI_UNIX
+#  define VCMI_LINUX
+#  ifdef __ANDROID__
+#    define VCMI_ANDROID 
+#  endif
 #elif defined(__APPLE__) && defined(__MACH__)
 #elif defined(__APPLE__) && defined(__MACH__)
-	#define VCMI_UNIX
-	#define VCMI_APPLE
-	#include "TargetConditionals.h"
-	#if TARGET_IPHONE_SIMULATOR
-		#define VCMI_IOS
-		#define VCMI_IOS_SIM
-	#elif TARGET_OS_IPHONE
-		#define VCMI_IOS
-	#elif TARGET_OS_MAC
-		#define VCMI_MAC
-	#else
-		//#warning "Unknown Apple target."?
-	#endif
+#  define VCMI_UNIX
+#  define VCMI_APPLE
+#  include "TargetConditionals.h"
+#  if TARGET_IPHONE_SIMULATOR
+#    define VCMI_IOS
+#    define VCMI_IOS_SIM
+#  elif TARGET_OS_IPHONE
+#    define VCMI_IOS
+#  elif TARGET_OS_MAC
+#    define VCMI_MAC
+#  else
+//#  warning "Unknown Apple target."?
+#  endif
 #else
 #else
-	#error "VCMI supports only Windows, OSX, Linux and Android targets"
+#  error "VCMI supports only Windows, OSX, Linux and Android targets"
 #endif
 #endif
 
 
 #ifdef VCMI_IOS
 #ifdef VCMI_IOS
-	#error "iOS system isn't yet supported."
+#  error "iOS system isn't yet supported."
 #endif
 #endif
 
 
 /* ---------------------------------------------------------------------------- */
 /* ---------------------------------------------------------------------------- */
 /* Commonly used C++, Boost headers */
 /* Commonly used C++, Boost headers */
 /* ---------------------------------------------------------------------------- */
 /* ---------------------------------------------------------------------------- */
 #ifdef VCMI_WINDOWS
 #ifdef VCMI_WINDOWS
-#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
-#define NOMINMAX				// Exclude min/max macros from <Windows.h>
+#  define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers - delete this line if something is missing.
+#  define NOMINMAX					// Exclude min/max macros from <Windows.h>. Use std::[min/max] from <algorithm> instead.
 #endif
 #endif
 
 
 #define _USE_MATH_DEFINES
 #define _USE_MATH_DEFINES
@@ -134,7 +134,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 
 
 #define BOOST_FILESYSTEM_VERSION 3
 #define BOOST_FILESYSTEM_VERSION 3
 #if BOOST_VERSION > 105000
 #if BOOST_VERSION > 105000
-#define BOOST_THREAD_VERSION 3
+#  define BOOST_THREAD_VERSION 3
 #endif
 #endif
 #define BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE 1
 #define BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE 1
 #define BOOST_BIND_NO_PLACEHOLDERS
 #define BOOST_BIND_NO_PLACEHOLDERS
@@ -199,28 +199,18 @@ typedef boost::lock_guard<boost::recursive_mutex> TLockGuardRec;
 // Import + Export macro declarations
 // Import + Export macro declarations
 #ifdef VCMI_WINDOWS
 #ifdef VCMI_WINDOWS
 #  ifdef __GNUC__
 #  ifdef __GNUC__
+#    define DLL_IMPORT __attribute__((dllimport))
 #    define DLL_EXPORT __attribute__((dllexport))
 #    define DLL_EXPORT __attribute__((dllexport))
 #  else
 #  else
+#    define DLL_IMPORT __declspec(dllimport)
 #    define DLL_EXPORT __declspec(dllexport)
 #    define DLL_EXPORT __declspec(dllexport)
 #  endif
 #  endif
 #  define ELF_VISIBILITY
 #  define ELF_VISIBILITY
 #else
 #else
 #  ifdef __GNUC__
 #  ifdef __GNUC__
+#    define DLL_IMPORT	__attribute__ ((visibility("default")))
 #    define DLL_EXPORT __attribute__ ((visibility("default")))
 #    define DLL_EXPORT __attribute__ ((visibility("default")))
 #    define ELF_VISIBILITY __attribute__ ((visibility("default")))
 #    define ELF_VISIBILITY __attribute__ ((visibility("default")))
-#  endif
-#endif
-
-#ifdef VCMI_WINDOWS
-#  ifdef __GNUC__
-#    define DLL_IMPORT __attribute__((dllimport))
-#  else
-#    define DLL_IMPORT __declspec(dllimport)
-#  endif
-#  define ELF_VISIBILITY
-#else
-#  ifdef __GNUC__
-#    define DLL_IMPORT	__attribute__ ((visibility("default")))
 #    define ELF_VISIBILITY __attribute__ ((visibility("default")))
 #    define ELF_VISIBILITY __attribute__ ((visibility("default")))
 #  endif
 #  endif
 #endif
 #endif

+ 1 - 1
client/CMT.cpp

@@ -203,7 +203,7 @@ int main(int argc, char** argv)
     OSX_checkForUpdates();
     OSX_checkForUpdates();
 
 
     // Check that game data is prepared. Otherwise run vcmibuilder helper application
     // Check that game data is prepared. Otherwise run vcmibuilder helper application
-    FILE* check = fopen((VCMIDirs::get().userDataPath() + "/game_data_prepared").c_str(), "r");
+    FILE* check = fopen((VCMIDirs::get().userDataPath() / "game_data_prepared").string().c_str(), "r");
     if (check == nullptr) {
     if (check == nullptr) {
         system("open ./vcmibuilder.app");
         system("open ./vcmibuilder.app");
         return 0;
         return 0;

+ 0 - 1
client/CVideoHandler.h

@@ -45,7 +45,6 @@ public:
 
 
 #if defined(VCMI_WINDOWS)  &&  (_MSC_VER < 1800 ||  !defined(USE_FFMPEG))
 #if defined(VCMI_WINDOWS)  &&  (_MSC_VER < 1800 ||  !defined(USE_FFMPEG))
 
 
-#define WIN32_LEAN_AND_MEAN //excludes rarely used stuff from windows headers - delete this line if something is missing
 #include <windows.h>
 #include <windows.h>
 
 
 #pragma pack(push,1)
 #pragma pack(push,1)

+ 0 - 1
lib/CConsoleHandler.cpp

@@ -27,7 +27,6 @@ DLL_LINKAGE CConsoleHandler * console = nullptr;
 	#define CONSOLE_GRAY "\x1b[1;30m"
 	#define CONSOLE_GRAY "\x1b[1;30m"
 	#define CONSOLE_TEAL "\x1b[1;36m"
 	#define CONSOLE_TEAL "\x1b[1;36m"
 #else
 #else
-	#define WIN32_LEAN_AND_MEAN //excludes rarely used stuff from windows headers - delete this line if something is missing
 	#include <Windows.h>
 	#include <Windows.h>
 #ifndef __MINGW32__
 #ifndef __MINGW32__
 	#include <dbghelp.h>
 	#include <dbghelp.h>

+ 0 - 1
lib/CGameInterface.cpp

@@ -5,7 +5,6 @@
 #include "VCMIDirs.h"
 #include "VCMIDirs.h"
 
 
 #ifdef VCMI_WINDOWS
 #ifdef VCMI_WINDOWS
-	#define WIN32_LEAN_AND_MEAN //excludes rarely used stuff from windows headers - delete this line if something is missing
 	#include <windows.h> //for .dll libs
 	#include <windows.h> //for .dll libs
 #else
 #else
 	#include <dlfcn.h>
 	#include <dlfcn.h>

+ 1 - 1
lib/VCMIDirs.cpp

@@ -463,7 +463,7 @@ bfs::path VCMIDirsLinux::userDataPath() const
 	const char* homeDir;
 	const char* homeDir;
 	if ((homeDir = getenv("XDG_DATA_HOME")))
 	if ((homeDir = getenv("XDG_DATA_HOME")))
 		return homeDir;
 		return homeDir;
-	else if (homeDir = getenv("HOME"))
+	else if ((homeDir = getenv("HOME")))
 		return bfs::path(homeDir) / ".local" / "share" / "vcmi";
 		return bfs::path(homeDir) / ".local" / "share" / "vcmi";
 	else
 	else
 		return ".";
 		return ".";