Added compiler tests and fixed MinGW warnings
Former-commit-id: 550d467e0997065943dc0b18a36d1be0edbb8114
This commit is contained in:
parent
f1eb859707
commit
1d217837cf
|
|
@ -37,20 +37,32 @@
|
||||||
|
|
||||||
///TODO: Rajouter des tests d'identification de compilateurs
|
///TODO: Rajouter des tests d'identification de compilateurs
|
||||||
// NAZARA_THREADLOCAL n'existe qu'en attendant le support complet de thread_local
|
// NAZARA_THREADLOCAL n'existe qu'en attendant le support complet de thread_local
|
||||||
#if defined(_MSC_VER)
|
#if defined(__BORLANDC__)
|
||||||
#define NAZARA_COMPILER_MSVC
|
#define NAZARA_COMPILER_BORDLAND
|
||||||
#define NAZARA_DEPRECATED(txt) __declspec(deprecated(txt))
|
#define NAZARA_DEPRECATED(txt)
|
||||||
#define NAZARA_FUNCTION __FUNCSIG__
|
#define NAZARA_FUNCTION __FUNC__
|
||||||
#define NAZARA_THREADLOCAL __declspec(thread)
|
#define NAZARA_THREADLOCAL __declspec(thread)
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__clang__)
|
||||||
|
#define NAZARA_COMPILER_CLANG
|
||||||
|
#define NAZARA_DEPRECATED(txt) __attribute__((__deprecated__(txt)))
|
||||||
|
#define NAZARA_FUNCTION __PRETTY_FUNCTION__
|
||||||
|
#define NAZARA_THREADLOCAL __declspec(thread)
|
||||||
|
#elif defined(__GNUC__) || defined(__MINGW32__)
|
||||||
#define NAZARA_COMPILER_GCC
|
#define NAZARA_COMPILER_GCC
|
||||||
#define NAZARA_DEPRECATED(txt) __attribute__((__deprecated__(txt)))
|
#define NAZARA_DEPRECATED(txt) __attribute__((__deprecated__(txt)))
|
||||||
#define NAZARA_FUNCTION __PRETTY_FUNCTION__
|
#define NAZARA_FUNCTION __PRETTY_FUNCTION__
|
||||||
#define NAZARA_THREADLOCAL __thread
|
#define NAZARA_THREADLOCAL __thread
|
||||||
#elif defined(__BORLANDC__)
|
|
||||||
#define NAZARA_COMPILER_BORDLAND
|
#ifdef __MINGW32__
|
||||||
#define NAZARA_DEPRECATED(txt)
|
#define NAZARA_COMPILER_MINGW
|
||||||
#define NAZARA_FUNCTION __FUNC__
|
#ifdef __MINGW64_VERSION_MAJOR
|
||||||
|
#define NAZARA_COMPILER_MINGW_W64
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
#define NAZARA_COMPILER_MSVC
|
||||||
|
#define NAZARA_DEPRECATED(txt) __declspec(deprecated(txt))
|
||||||
|
#define NAZARA_FUNCTION __FUNCSIG__
|
||||||
#define NAZARA_THREADLOCAL __declspec(thread)
|
#define NAZARA_THREADLOCAL __declspec(thread)
|
||||||
#else
|
#else
|
||||||
#define NAZARA_COMPILER_UNKNOWN
|
#define NAZARA_COMPILER_UNKNOWN
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,14 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// C'est malheureux mais le spécificateur %z de (f)printf n'est pas supporté partout
|
||||||
|
#ifdef NAZARA_COMPILER_MINGW
|
||||||
|
#define SIZE_T_SPECIFIER "%u"
|
||||||
|
#else
|
||||||
|
#define SIZE_T_SPECIFIER "%zu" // Standard
|
||||||
|
#endif
|
||||||
|
// Le seul fichier n'ayant pas à inclure Debug.hpp
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct Block
|
struct Block
|
||||||
|
|
@ -76,7 +84,7 @@ void* NzMemoryManager::Allocate(std::size_t size, bool multi, const char* file,
|
||||||
{
|
{
|
||||||
// Pas d'information de temps (Car nécessitant une allocation)
|
// Pas d'information de temps (Car nécessitant une allocation)
|
||||||
FILE* log = std::fopen(MLTFileName, "a");
|
FILE* log = std::fopen(MLTFileName, "a");
|
||||||
std::fprintf(log, "Failed to allocate memory (%zu bytes)\n", size);
|
std::fprintf(log, "Failed to allocate memory (" SIZE_T_SPECIFIER " bytes)\n", size);
|
||||||
std::fclose(log);
|
std::fclose(log);
|
||||||
|
|
||||||
return nullptr; // Impossible d'envoyer une exception car cela allouerait de la mémoire avec new (boucle infinie)
|
return nullptr; // Impossible d'envoyer une exception car cela allouerait de la mémoire avec new (boucle infinie)
|
||||||
|
|
@ -232,9 +240,9 @@ void NzMemoryManager::Uninitialize()
|
||||||
count++;
|
count++;
|
||||||
totalSize += ptr->size;
|
totalSize += ptr->size;
|
||||||
if (ptr->file)
|
if (ptr->file)
|
||||||
std::fprintf(log, "-0x%p -> %zu bytes allocated at %s:%u\n", reinterpret_cast<char*>(ptr)+sizeof(Block), ptr->size, ptr->file, ptr->line);
|
std::fprintf(log, "-0x%p -> " SIZE_T_SPECIFIER " bytes allocated at %s:%u\n", reinterpret_cast<char*>(ptr)+sizeof(Block), ptr->size, ptr->file, ptr->line);
|
||||||
else
|
else
|
||||||
std::fprintf(log, "-0x%p -> %zu bytes allocated at unknown position\n", reinterpret_cast<char*>(ptr)+sizeof(Block), ptr->size);
|
std::fprintf(log, "-0x%p -> " SIZE_T_SPECIFIER " bytes allocated at unknown position\n", reinterpret_cast<char*>(ptr)+sizeof(Block), ptr->size);
|
||||||
|
|
||||||
void* pointer = ptr;
|
void* pointer = ptr;
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue