cpp-utilities/application/global.h

106 lines
2.9 KiB
C
Raw Normal View History

2019-06-12 20:34:25 +02:00
#ifndef CPP_UTILITIES_APPLICATION_UTILITIES_GLOBAL_H
#define CPP_UTILITIES_APPLICATION_UTILITIES_GLOBAL_H
2016-09-10 16:00:20 +02:00
#if defined(_WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
2017-05-01 03:13:11 +02:00
#ifndef PLATFORM_WINDOWS
/// \brief Defined when compiling for Windows.
2017-05-01 03:13:11 +02:00
#define PLATFORM_WINDOWS
#endif
#endif
2016-09-10 16:00:20 +02:00
#if defined(__CYGWIN__)
2017-05-01 03:13:11 +02:00
#ifndef PLATFORM_CYGWIN
2016-09-10 16:00:20 +02:00
/// \brief Defined when compiling for Cygwin.
2017-05-01 03:13:11 +02:00
#define PLATFORM_CYGWIN
#endif
2016-09-10 16:00:20 +02:00
#endif
2017-05-01 03:13:11 +02:00
#if defined(__MINGW32__) || defined(__MINGW64__)
#ifndef PLATFORM_MINGW
/// \brief Defined when compiling with mingw(-w64).
2017-05-01 03:13:11 +02:00
#define PLATFORM_MINGW
#endif
#endif
2016-09-10 16:00:20 +02:00
#if defined(__linux__) || defined(__linux) || defined(__gnu_linux__)
2017-05-01 03:13:11 +02:00
#ifndef PLATFORM_LINUX
/// \brief Defined when compiling for Linux.
2017-05-01 03:13:11 +02:00
#define PLATFORM_LINUX
#endif
#if defined(__ANDROID__) || defined(ANDROID)
#ifndef PLATFORM_ANDROID
2016-09-10 16:00:20 +02:00
/// \brief Defined when compiling for Android.
2017-05-01 03:13:11 +02:00
#define PLATFORM_ANDROID
#endif
#endif
2016-09-10 16:00:20 +02:00
#endif
#if defined(__APPLE__)
2017-05-01 03:13:11 +02:00
#include <TargetConditionals.h>
#if defined(TARGET_OS_MAC) && TARGET_OS_MAC
#ifndef PLATFORM_MAC
2016-09-10 16:00:20 +02:00
/// \brief Defined when compiling for Mac/Darwin.
2017-05-01 03:13:11 +02:00
#define PLATFORM_MAC
#endif
#ifndef PLATFORM_BSD4
2016-09-10 16:00:20 +02:00
/// \brief Defined when compiling for BSD 4.
2017-05-01 03:13:11 +02:00
#define PLATFORM_BSD4
#endif
#endif
2016-09-10 16:00:20 +02:00
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
2017-05-01 03:13:11 +02:00
#ifndef PLATFORM_FREE_BSD
2016-09-10 16:00:20 +02:00
/// \brief Defined when compiling for FreeBSD
2017-05-01 03:13:11 +02:00
#define PLATFORM_FREE_BSD
#endif
#endif
#if defined(__unix__) || defined(PLATFORM_LINUX) || defined(PLATFORM_FREE_BSD) || defined(PLATFORM_MAC)
2017-05-01 03:13:11 +02:00
#ifndef PLATFORM_UNIX
/// \brief Defined when compiling for any UNIX (like) system.
2017-05-01 03:13:11 +02:00
#define PLATFORM_UNIX
#endif
#endif
/*!
2019-06-12 20:34:25 +02:00
* \def CPP_UTILITIES_GENERIC_LIB_EXPORT
* \brief Marks a symbol for shared library export.
*/
/*!
2019-06-12 20:34:25 +02:00
* \def CPP_UTILITIES_GENERIC_LIB_IMPORT
* \brief Declares a symbol to be an import from a shared library.
*/
/*!
2019-06-12 20:34:25 +02:00
* \def CPP_UTILITIES_GENERIC_LIB_HIDDEN
* \brief Hidden visibility indicates that the symbol will not be placed into
* the dynamic symbol table, so no other module (executable or shared library)
* can reference it directly.
*/
#ifdef PLATFORM_WINDOWS
2019-06-12 20:34:25 +02:00
#define CPP_UTILITIES_GENERIC_LIB_EXPORT __declspec(dllexport)
#define CPP_UTILITIES_GENERIC_LIB_IMPORT __declspec(dllimport)
#define CPP_UTILITIES_GENERIC_LIB_HIDDEN
#else
2019-06-12 20:34:25 +02:00
#define CPP_UTILITIES_GENERIC_LIB_EXPORT __attribute__((visibility("default")))
#define CPP_UTILITIES_GENERIC_LIB_IMPORT __attribute__((visibility("default")))
#define CPP_UTILITIES_GENERIC_LIB_HIDDEN __attribute__((visibility("hidden")))
#endif
/*!
2019-06-12 20:34:25 +02:00
* \def CPP_UTILITIES_UNUSED
* \brief Prevents warnings about unused variables.
*/
2019-06-12 20:34:25 +02:00
#define CPP_UTILITIES_UNUSED(x) (void)x;
/*!
2019-06-12 20:34:25 +02:00
* \def CPP_UTILITIES_IF_DEBUG_BUILD
* \brief Wraps debug-only lines conveniently.
*/
2019-06-12 20:34:25 +02:00
#ifdef CPP_UTILITIES_DEBUG_BUILD
#define CPP_UTILITIES_IF_DEBUG_BUILD(x) x
#else
2019-06-12 20:34:25 +02:00
#define CPP_UTILITIES_IF_DEBUG_BUILD(x)
#endif
2019-06-12 20:34:25 +02:00
#endif // CPP_UTILITIES_APPLICATION_UTILITIES_GLOBAL_H