cpp-utilities/application/global.h

90 lines
1.9 KiB
C
Raw Normal View History

#ifndef APPLICATION_UTILITIES_GLOBAL_H
#define APPLICATION_UTILITIES_GLOBAL_H
2015-04-22 18:36:40 +02:00
2016-06-10 14:08:56 +02:00
#ifdef _WIN32
# ifndef PLATFORM_WINDOWS
2015-04-22 18:36:40 +02:00
/*!
* \brief Defined on Windows.
*/
2016-03-03 01:44:26 +01:00
# define PLATFORM_WINDOWS
# endif
2015-04-22 18:36:40 +02:00
#elif __unix__
2016-03-03 01:44:26 +01:00
# ifndef PLATFORM_UNIX
2016-06-10 14:08:56 +02:00
/*!
* \brief Defined on any UNIX system.
*/
2016-03-03 01:44:26 +01:00
# define PLATFORM_UNIX
# endif
2015-04-22 18:36:40 +02:00
#endif
#ifdef __linux__
2016-03-03 01:44:26 +01:00
# ifndef PLATFORM_LINUX
2016-06-10 14:08:56 +02:00
/*!
* \brief Defined on Linux.
*/
2016-03-03 01:44:26 +01:00
# define PLATFORM_LINUX
# endif
2015-04-22 18:36:40 +02:00
#endif
/*!
* \def LIB_EXPORT
2016-06-10 14:08:56 +02:00
* \brief Marks a symbol for shared library export.
2015-04-22 18:36:40 +02:00
*/
/*!
* \def LIB_IMPORT
2016-06-10 14:08:56 +02:00
* \brief Declares a symbol to be an import from a shared library.
2015-04-22 18:36:40 +02:00
*/
/*!
* \def 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
# define LIB_EXPORT __declspec(dllexport)
# define LIB_IMPORT __declspec(dllimport)
# define LIB_HIDDEN
#else
# define LIB_EXPORT __attribute__((visibility("default")))
# define LIB_IMPORT __attribute__((visibility("default")))
# define LIB_HIDDEN __attribute__((visibility("hidden")))
#endif
/*!
* \def USE_NOTHROW
2016-06-10 14:08:56 +02:00
* \brief Marks a function as never throwing, under no circumstances.
* \remarks If the function does nevertheless throw, the behaviour is undefined.
2015-04-22 18:36:40 +02:00
*/
2016-03-03 01:44:26 +01:00
#ifndef USE_NOTHROW
# if __cplusplus >= 201103L
# define USE_NOTHROW noexcept
# else
# define USE_NOTHROW throw()
# endif
2015-04-22 18:36:40 +02:00
#endif
/*!
* \def DECLARE_ENUM
2016-06-10 14:08:56 +02:00
* \brief Forward-declares enums without preventing lupdate to parse the file correctly.
2015-04-22 18:36:40 +02:00
*/
#define DECLARE_ENUM(name, base) enum class name : base;
#define VAR_UNUSED(x) (void)x;
2016-05-26 02:19:44 +02:00
/*!
* \def IF_DEBUG_BUILD
* \brief Wraps debug-only lines conveniently.
*/
#ifdef DEBUG_BUILD
# define IF_DEBUG_BUILD(x) x
#else
# define IF_DEBUG_BUILD(x)
#endif
#endif // APPLICATION_UTILITIES_GLOBAL_H