Preproc symbols to detect architecture/os.
For details see: http://sourceforge.net/p/predef/wiki/Home/ Symbol SAILFISHOS is untested and likely has to be passed to the compiler from the outside.
This commit is contained in:
parent
7bf96669a5
commit
a7b321feb3
4 changed files with 124 additions and 0 deletions
|
@ -7,4 +7,6 @@
|
|||
# define DATA_PATH ""
|
||||
#endif
|
||||
|
||||
#define APP_NAME "@PROJECT_NAME@"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "doorkeeper.hpp"
|
||||
#include "doorkeeperConfig.h"
|
||||
#include "platform.h"
|
||||
#include "platformstrings.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
@ -8,6 +10,8 @@ int main() {
|
|||
typedef dk::Tyler<2> Tiler;
|
||||
typedef std::unique_ptr<std::ifstream> ifstreamptr;
|
||||
|
||||
std::cout << "Welcome to " << APP_NAME << ' ' << DK_DEVICE_STRING << " version for " << DK_OS_STRING << ' ' << DK_ARCH_STRING << ' ' << DK_BIT_STRING << '\n';
|
||||
|
||||
Tiler tiler(Tiler::coords(10, 6), Tiler::coords(64));
|
||||
|
||||
const std::string map1(DATA_PATH"/test.map");
|
||||
|
|
71
src/platform.h
Normal file
71
src/platform.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
#ifndef id054C8BCA27C84EAA825922EC0A4F3317
|
||||
#define id054C8BCA27C84EAA825922EC0A4F3317
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
# define DK_POSIX
|
||||
# define DK_ANDROID
|
||||
# define DK_MOBILE
|
||||
#elif defined(SAILFISHOS)
|
||||
# define DK_POSIX
|
||||
# define DK_SAILFISHOS
|
||||
# define DK_MOBILE
|
||||
#elif defined(__gnu_linux__) || defined(__linux__) || defined(linux)
|
||||
# define DK_POSIX
|
||||
# define DK_LINUX
|
||||
# define DK_PC
|
||||
#elif defined(_WIN16) || defined(_WIN32) || defined(_WIN64) || \
|
||||
defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__)
|
||||
# if defined(_WIN32) || defined(__WIN32__)
|
||||
# define DK_WIN32
|
||||
# endif
|
||||
# define DK_WINDOWS
|
||||
# define DK_PC
|
||||
#else
|
||||
# error "Unknown platform"
|
||||
#endif
|
||||
|
||||
#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || \
|
||||
defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
|
||||
# define DK_X86_64
|
||||
# define DK_64_BIT
|
||||
#elif defined(__arm__)
|
||||
# if defined(__ARM_ARCH_6__)
|
||||
# define DK_ARM_VERSION 6
|
||||
# elif defined(__ARM_ARCH_7__)
|
||||
# define DK_ARM_VERSION 7
|
||||
# else
|
||||
# error "Unknown ARM version"
|
||||
# endif
|
||||
# define DK_32_BIT
|
||||
# define DK_ARM
|
||||
#elif defined(_M_ARM)
|
||||
# if _M_ARM != 6 && _M_ARM != 7
|
||||
# error "Unknown ARM version"
|
||||
# endif
|
||||
# define DK_ARM_VERSION _M_ARM
|
||||
# define DK_32_BIT
|
||||
# define DK_ARM
|
||||
#elif defined(__TARGET_ARCH_ARM)
|
||||
# if __TARGET_ARCH_ARM != 6 && __TARGET_ARCH_ARM != 7
|
||||
# error "Unknown ARM version"
|
||||
# endif
|
||||
# define DK_ARM_VERSION __TARGET_ARCH_ARM
|
||||
# define DK_32_BIT
|
||||
# define DK_ARM
|
||||
#elif defined(__aarch64__)
|
||||
# define DK_ARM
|
||||
# define DK_64_BIT
|
||||
#elif defined(i386) || defined(__i386) || defined(__i386__) || \
|
||||
defined(__i486__) || defined(__i586__) || defined(__i686__) || \
|
||||
defined(_M_I86) || defined(_M_IX86) || defined(_X86_) || defined(__INTEL__)
|
||||
# define DK_X86
|
||||
# define DK_32_BIT
|
||||
#elif defined(__ia64__) || defined(_IA64) || defined(__IA64__) || \
|
||||
defined(_M_IA64) || defined(__itanium__)
|
||||
# define DK_IA64
|
||||
# define DK_64_BIT
|
||||
#else
|
||||
# error "Unknown architecture"
|
||||
#endif
|
||||
|
||||
#endif
|
47
src/platformstrings.h
Normal file
47
src/platformstrings.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
#ifndef id2802AD0DCAF7443CA095A5AAF417015E
|
||||
#define id2802AD0DCAF7443CA095A5AAF417015E
|
||||
|
||||
#define STR1_LOC(x) #x
|
||||
#define STRINGIZE(x) STR1_LOC(x)
|
||||
|
||||
#if defined(DK_64_BIT)
|
||||
# define DK_BIT_STRING "64-bit"
|
||||
#elif defined(DK_32_BIT)
|
||||
# define DK_BIT_STRING "32-bit"
|
||||
#else
|
||||
# error "No registry size defined"
|
||||
#endif
|
||||
|
||||
#if defined(DK_ARM)
|
||||
# if defined(DK_32_BIT)
|
||||
# define DK_ARCH_STRING "ARMv" STRINGIZE(DK_ARM_VERSION)
|
||||
# else
|
||||
# define DK_ARCH_STRING "ARM"
|
||||
# endif
|
||||
#elif defined(DK_X86)
|
||||
# define DK_ARCH_STRING "x86"
|
||||
#elif defined(DK_X86_64)
|
||||
# define DK_ARCH_STRING "amd64"
|
||||
#elif defined(DK_IA64)
|
||||
# define DK_ARCH_STRING "ia64"
|
||||
#else
|
||||
# error "No architecture defined"
|
||||
#endif
|
||||
|
||||
#if defined(DK_LINUX)
|
||||
# define DK_OS_STRING "Linux"
|
||||
#elif defined(DK_WINDOWS)
|
||||
# define DK_OS_STRING "Windows"
|
||||
#elif defined(DK_ANDROID)
|
||||
# define DK_OS_STRING "Android"
|
||||
#endif
|
||||
|
||||
#if defined(DK_PC)
|
||||
# define DK_DEVICE_STRING "PC"
|
||||
#elif defined(DK_MOBILE)
|
||||
# define DK_DEVICE_STRING "Mobile"
|
||||
#else
|
||||
# error "No device type defined"
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue