summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/Globals.h65
-rw-r--r--source/NBT.cpp4
-rw-r--r--source/NBT.h4
-rw-r--r--source/WorldStorage.h2
-rw-r--r--source/cCriticalSection.h6
-rw-r--r--source/main.cpp4
6 files changed, 57 insertions, 28 deletions
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 <Windows.h>
- #include <winsock.h>
+ #include <winsock2.h>
#else
#include <sys/types.h>
#include <sys/stat.h> // 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) )
diff --git a/source/NBT.cpp b/source/NBT.cpp
index c600a1868..928ef8080 100644
--- a/source/NBT.cpp
+++ b/source/NBT.cpp
@@ -622,7 +622,7 @@ cNBTTree * cNBTParser::Parse(const char * a_Data, int a_Length)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Dumping the NBT tree (debug-only)
-#ifdef _DEBUG
+#if (defined(_DEBUG) && defined(_WIN32))
#define CASE_SIMPLE_TAG(TYPE,FMT) \
case cNBTTag::TAG_##TYPE: \
@@ -696,7 +696,7 @@ void DumpTree(const cNBTTree * a_Tree, int a_Level)
#undef CASE_SIMPLE_TAG
-#endif // _DEBUG
+#endif // (_DEBUG && _WIN32)
diff --git a/source/NBT.h b/source/NBT.h
index a05e574de..75ff6e361 100644
--- a/source/NBT.h
+++ b/source/NBT.h
@@ -203,9 +203,9 @@ public:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Dumping the tree (DEBUG-only)
-#ifdef _DEBUG
+#if (defined(_DEBUG) && defined(_WIN32))
void DumpTree(const cNBTTree * a_Tree, int a_Level = 0);
-#endif // _DEBUG
+#endif // (_DEBUG && _WIN32)
diff --git a/source/WorldStorage.h b/source/WorldStorage.h
index 689d5f1ef..0845a7ce7 100644
--- a/source/WorldStorage.h
+++ b/source/WorldStorage.h
@@ -31,7 +31,7 @@ class cBlockEntity;
/// Interface that all the world storage schemas need to implement
-class cWSSchema ABSTRACT
+class cWSSchema abstract
{
public:
cWSSchema(cWorld * a_World) : m_World(a_World) {}
diff --git a/source/cCriticalSection.h b/source/cCriticalSection.h
index 414c970f7..0a149a95a 100644
--- a/source/cCriticalSection.h
+++ b/source/cCriticalSection.h
@@ -19,10 +19,10 @@ private:
#ifdef _WIN32
CRITICAL_SECTION m_CriticalSection;
#else // _WIN32
- void* m_CriticalSectionPtr; // Pointer to a CRITICAL_SECTION object
- void* m_Attributes;
+ void* m_CriticalSectionPtr ALIGN_8; // Pointer to a CRITICAL_SECTION object
+ void* m_Attributes ALIGN_8;
#endif // else _WIN32
-};
+} ALIGN_8;
diff --git a/source/main.cpp b/source/main.cpp
index f19a88210..1d245ae0b 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -158,14 +158,14 @@ int main( int argc, char **argv )
#endif // _WIN32 && !_WIN64
// End of dump-file magic
- #ifdef _DEBUG
+ #if defined(_DEBUG) && defined(_MSC_VER)
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
// _X: The simple built-in CRT leak finder - simply break when allocating the Nth block ({N} is listed in the leak output)
// Only useful when the leak is in the same sequence all the time
// _CrtSetBreakAlloc(85950);
- #endif
+ #endif // _DEBUG && _MSC_VER
#ifndef _DEBUG
std::signal(SIGSEGV, ShowCrashReport);