File: global.h

package info (click to toggle)
martchus-cpp-utilities 5.28.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,352 kB
  • sloc: cpp: 12,471; awk: 18; ansic: 12; makefile: 10
file content (121 lines) | stat: -rw-r--r-- 3,581 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef CPP_UTILITIES_APPLICATION_UTILITIES_GLOBAL_H
#define CPP_UTILITIES_APPLICATION_UTILITIES_GLOBAL_H

#if defined(_WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
#ifndef PLATFORM_WINDOWS
/// \brief Defined when compiling for Windows.
#define PLATFORM_WINDOWS
#endif
#endif
#if defined(__CYGWIN__)
#ifndef PLATFORM_CYGWIN
/// \brief Defined when compiling for Cygwin.
#define PLATFORM_CYGWIN
#endif
#endif
#if defined(__MINGW32__) || defined(__MINGW64__)
#ifndef PLATFORM_MINGW
/// \brief Defined when compiling with mingw(-w64).
#define PLATFORM_MINGW
#endif
#endif
#if defined(__linux__) || defined(__linux) || defined(__gnu_linux__)
#ifndef PLATFORM_LINUX
/// \brief Defined when compiling for Linux.
#define PLATFORM_LINUX
#endif
#if defined(__ANDROID__) || defined(ANDROID)
#ifndef PLATFORM_ANDROID
/// \brief Defined when compiling for Android.
#define PLATFORM_ANDROID
#endif
#endif
#endif
#if defined(__APPLE__)
#include <TargetConditionals.h>
#if defined(TARGET_OS_MAC) && TARGET_OS_MAC
#ifndef PLATFORM_MAC
/// \brief Defined when compiling for Mac/Darwin.
#define PLATFORM_MAC
#endif
#ifndef PLATFORM_BSD4
/// \brief Defined when compiling for BSD 4.
#define PLATFORM_BSD4
#endif
#endif
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
#ifndef PLATFORM_FREE_BSD
/// \brief Defined when compiling for FreeBSD
#define PLATFORM_FREE_BSD
#endif
#endif
#if defined(__unix__) || defined(PLATFORM_LINUX) || defined(PLATFORM_FREE_BSD) || defined(PLATFORM_MAC)
#ifndef PLATFORM_UNIX
/// \brief Defined when compiling for any UNIX (like) system.
#define PLATFORM_UNIX
#endif
#endif

/*!
 * \def CPP_UTILITIES_GENERIC_LIB_EXPORT
 * \brief Marks a symbol for shared library export.
 */

/*!
 * \def CPP_UTILITIES_GENERIC_LIB_IMPORT
 * \brief Declares a symbol to be an import from a shared library.
 */

/*!
 * \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
#define CPP_UTILITIES_GENERIC_LIB_EXPORT __declspec(dllexport)
#define CPP_UTILITIES_GENERIC_LIB_IMPORT __declspec(dllimport)
#define CPP_UTILITIES_GENERIC_LIB_HIDDEN
#else
#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

/*!
 * \def CPP_UTILITIES_MAIN_EXPORT
 * \brief Exports the main() functions on platforms where this is needed.
 * \remarks Needed on Android with Qt where applications are shared libraries.
 *          Otherwise loading the app will fail with the error "dlsym failed: undefined
 *          symbol: main".
 * \sa See qtbase commit 29b17fa335388c9b93f70c29b2398cf2fee65785 (where this is solved
       with the sledgehammer method of setting the default visibility).
 */

#ifdef PLATFORM_ANDROID
#define CPP_UTILITIES_MAIN_EXPORT CPP_UTILITIES_GENERIC_LIB_EXPORT
#else
#define CPP_UTILITIES_MAIN_EXPORT
#endif

/*!
 * \def CPP_UTILITIES_UNUSED
 * \brief Prevents warnings about unused variables.
 */

#define CPP_UTILITIES_UNUSED(x) (void)x;

/*!
 * \def CPP_UTILITIES_IF_DEBUG_BUILD
 * \brief Wraps debug-only lines conveniently.
 */

#ifdef CPP_UTILITIES_DEBUG_BUILD
#define CPP_UTILITIES_IF_DEBUG_BUILD(x) x
#else
#define CPP_UTILITIES_IF_DEBUG_BUILD(x)
#endif

#endif // CPP_UTILITIES_APPLICATION_UTILITIES_GLOBAL_H