PoDoFo 1.0.0-dev
Loading...
Searching...
No Matches
basedefs.h
1
7#ifndef PODOFO_BASE_DEFS_H
8#define PODOFO_BASE_DEFS_H
9
10/*
11 * This header provides a macro to handle correct symbol imports/exports
12 * on platforms that require explicit instructions to make symbols public,
13 * or differentiate between exported and imported symbols.
14 *
15 * Win32 compilers use this information, and gcc4 can use it on *nix
16 * to reduce the size of the export symbol table and get faster runtime
17 * linking.
18 *
19 * All declarations of public API should be marked with the PODOFO_API macro.
20 * Separate definitions need not be annotated, even in headers.
21 *
22 * Usage examples:
23 *
24 * class PODOFO_API PdfArray : public PdfDataContainer {
25 * ...
26 * };
27 *
28 * bool PODOFO_API doThatThing();
29 *
30 * For an exception type that may be thrown across a DSO boundary, you must
31 * use:
32 *
33 * class PODOFO_EXCEPTION_API(PODOFO_API) MyException
34 * {
35 * ...
36 * };
37 *
38 */
39
40// Sanity check, can't compile both shared and static library
41#if defined(PODOFO_SHARED) && defined(PODOFO_STATIC)
42 #error "Both PODOFO_SHARED and PODOFO_STATIC defined!"
43#endif
44
45#ifdef PODOFO_STATIC
46
47#define PODOFO_API
48#define PODOFO_EXPORT
49#define PODOFO_IMPORT
50
51#else // PODOFO_SHARED
52#ifndef PODOFO_SHARED
53#define PODOFO_SHARED
54#endif
55
56#if defined(_MSC_VER)
57 #define PODOFO_EXPORT __declspec(dllexport)
58 #define PODOFO_IMPORT __declspec(dllimport)
59#else
60 // NOTE: In non MSVC compilers https://gcc.gnu.org/wiki/Visibility,
61 // it's not necessary to distinct between exporting and importing
62 // the symbols and for correct working of RTTI features is better
63 // always set default visibility both when compiling and when using
64 // the library. The symbol will not be re-exported by other libraries
65 #define PODOFO_EXPORT __attribute__ ((visibility("default")))
66 #define PODOFO_IMPORT __attribute__ ((visibility("default")))
67#endif
68
69#if defined(PODOFO_BUILD)
70#define PODOFO_API PODOFO_EXPORT
71#else
72#define PODOFO_API PODOFO_IMPORT
73#endif
74
75#endif
76
77// Throwable classes must always be exported by all binaries when
78// using gcc. Marking exception classes with PODOFO_EXCEPTION_API
79// ensures this.
80#ifdef _WIN32
81 #define PODOFO_EXCEPTION_API(api) api
82#else
83 #define PODOFO_EXCEPTION_API(api) PODOFO_API
84#endif
85
86// Set up some other compiler-specific but not platform-specific macros
87
88#ifdef __GNU__
89 #define PODOFO_HAS_GCC_ATTRIBUTE_DEPRECATED 1
90#elif defined(__has_attribute)
91 #if __has_attribute(__deprecated__)
92 #define PODOFO_HAS_GCC_ATTRIBUTE_DEPRECATED 1
93 #endif
94#endif
95
96#ifdef PODOFO_HAS_GCC_ATTRIBUTE_DEPRECATED
97 // gcc (or compat. clang) will issue a warning if a function or variable so annotated is used
98 #define PODOFO_DEPRECATED __attribute__((__deprecated__))
99#else
100 #define PODOFO_DEPRECATED
101#endif
102
103// Specify the friend identifier is defined in private symbols only
104#define PODOFO_PRIVATE_FRIEND(identifier)
105
106// Include some useful compatibility defines
107#include "basecompat.h"
108
109// Include the configuration file
110#include "podofo_config.h"
111
112#endif // PODOFO_BASE_DEFS_H