From 11810e05e40e24de14a3f0213f978853ba632e9f Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Fri, 9 Mar 2012 09:39:48 +0000 Subject: Using the _DEBUG macro for *nix debug builds as well; trying to force 8-byte alignment on critical sections ( http://forum.mc-server.org/showthread.php?tid=384 ) git-svn-id: http://mc-server.googlecode.com/svn/trunk@387 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Globals.h | 65 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 18 deletions(-) (limited to 'source/Globals.h') diff --git a/source/Globals.h b/source/Globals.h index 0d6694e11..6291c51e8 100644 --- a/source/Globals.h +++ b/source/Globals.h @@ -9,18 +9,57 @@ // Compiler-dependent stuff: -#ifndef _MSC_VER - // Non-MS compilers don't know the override keyword - #define override - #define abstract - #define stricmp strcasecmp -#else +#if defined(_MSC_VER) // MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether #pragma warning(disable:4481) // Disable some warnings that we don't care about: #pragma warning(disable:4100) -#endif // _MSC_VER + + #define OBSOLETE __declspec(deprecated) + + // No alignment needed in MSVC + #define ALIGN_8 + #define ALIGN_16 + +#elif defined(__GNUC__) + + // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)? + #define abstract + + // TODO: Can GCC mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class) + #define override + + #define OBSOLETE __attribute__((deprecated)) + + #define ALIGN_8 __attribute__((aligned(8))) + #define ALIGN_16 __attribute__((aligned(16))) + + // Some portability macros :) + #define stricmp strcasecmp + +#else + + #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler" + + /* + // Copy and uncomment this into another #elif section based on your compiler identification + + // Explicitly mark classes as abstract (no instances can be created) + #define abstract + + // Mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class) + #define override + + // Mark functions as obsolete, so that their usage results in a compile-time warning + #define OBSOLETE + + // Mark types / variables for alignment. Do the platforms need it? + #define ALIGN_8 + #define ALIGN_16 + */ + +#endif @@ -40,7 +79,7 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include - #include + #include #else #include #include // for mkdir @@ -112,16 +151,6 @@ /// Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)" ) #define KiB * 1024 -#ifdef _MSC_VER - #define OBSOLETE __declspec(deprecated) - #define ABSTRACT abstract -#else - // TODO: how do other compilers mark functions as obsolete, so that their usage results in a compile-time warning? - #define OBSOLETE - // TODO: Can other compilers explicitly mark classes as abstract (no instances can be created)? - #define ABSTRACT -#endif - /// Faster than (int)floorf((float)x / (float)div) #define FAST_FLOOR_DIV( x, div ) ( (x) < 0 ? (((int)x / div) - 1) : ((int)x / div) ) -- cgit v1.2.3