mirror of
https://github.com/edubart/otclient.git
synced 2025-10-20 22:43:27 +02:00
Visual Studio 2013 Compatibility
This commit is contained in:
@@ -25,10 +25,23 @@
|
||||
|
||||
#ifdef __clang__
|
||||
// clang is supported
|
||||
#define BUILD_COMPILER "clang " __VERSION__
|
||||
#elif defined(__GNUC__)
|
||||
#if !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
|
||||
#error "Sorry, you need gcc 4.6 or greater to compile."
|
||||
#endif
|
||||
#define BUILD_COMPILER "gcc " __VERSION__
|
||||
#elif defined(_MSC_VER)
|
||||
#if _MSC_VER < 1800
|
||||
#error "You need Visual Studio 2013 or greater to compile."
|
||||
#endif
|
||||
#pragma warning(disable:4244) // conversion from 'A' to 'B', possible loss of data
|
||||
#pragma warning(disable:4305) // 'initializing' : truncation from 'A' to 'B'
|
||||
#pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned
|
||||
#pragma warning(disable:4800) // 'A' : forcing value to bool 'true' or 'false' (performance warning)
|
||||
|
||||
#define BUILD_COMPILER "msvc12"
|
||||
#define __PRETTY_FUNCTION__ __FUNCDNAME__
|
||||
#else
|
||||
#error "Compiler not supported."
|
||||
#endif
|
||||
@@ -44,12 +57,8 @@
|
||||
#define unlikely(x) (x)
|
||||
#endif
|
||||
|
||||
#if !defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
#if !defined(_MSC_VER) && !defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
#error "C++0x is required to compile this application. Try updating your compiler."
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#warning "MSVC lacks some C++11 features used in this application; compilation is most likely to fail."
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -22,14 +22,24 @@
|
||||
|
||||
#include "demangle.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#else
|
||||
#include <cxxabi.h>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
namespace stdext {
|
||||
|
||||
const char* demangle_name(const char* name)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
static char buffer[1024];
|
||||
UnDecorateSymbolName(name, buffer, sizeof(buffer), UNDNAME_COMPLETE);
|
||||
return &buffer[6];
|
||||
#else
|
||||
size_t len;
|
||||
int status;
|
||||
static char buffer[1024];
|
||||
@@ -39,6 +49,7 @@ const char* demangle_name(const char* name)
|
||||
free(demangled);
|
||||
}
|
||||
return buffer;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -55,8 +55,14 @@ template<int N> struct expand_snprintf {
|
||||
template<typename Tuple, typename... Args> static int call(char *s, size_t maxlen, const char *format, const Tuple& tuple, const Args&... args) {
|
||||
return expand_snprintf<N-1>::call(s, maxlen, format, tuple, sprintf_cast(std::get<N-1>(tuple)), args...); }};
|
||||
template<> struct expand_snprintf<0> {
|
||||
#ifdef _MSC_VER
|
||||
template<typename Tuple, typename... Args> static int call(char *s, size_t maxlen, const char *format, const Tuple& tuple, const Args&... args) {
|
||||
return snprintf(s, maxlen, format, args...); }};
|
||||
return _snprintf(s, maxlen, format, args...); }
|
||||
#else
|
||||
template<typename Tuple, typename... Args> static int call(char *s, size_t maxlen, const char *format, const Tuple& tuple, const Args&... args) {
|
||||
return snprintf(s, maxlen, format, args...); }
|
||||
#endif
|
||||
};
|
||||
|
||||
// Improved snprintf that accepts std::string and other types
|
||||
template<typename... Args>
|
||||
|
@@ -22,7 +22,11 @@
|
||||
|
||||
#include "time.h"
|
||||
#include <boost/chrono.hpp>
|
||||
#ifdef _MSC_VER
|
||||
#include <thread>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace stdext {
|
||||
|
||||
@@ -42,12 +46,20 @@ ticks_t micros() {
|
||||
|
||||
void millisleep(size_t ms)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
||||
#else
|
||||
usleep(ms * 1000);
|
||||
#endif
|
||||
};
|
||||
|
||||
void microsleep(size_t us)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(us));
|
||||
#else
|
||||
usleep(us);
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user