PoDoFo 1.1.0
Loading...
Searching...
No Matches
basedefs.h
1// SPDX-FileCopyrightText: 2005 Dominik Seichter <domseichter@web.de>
2// SPDX-FileCopyrightText: 2020 Francesco Pretto <ceztko@gmail.com>
3// SPDX-License-Identifier: LGPL-2.0-or-later OR MPL-2.0
4
5#ifndef PODOFO_BASE_DEFS_H
6#define PODOFO_BASE_DEFS_H
7
8/*
9 * This header provides a macro to handle correct symbol imports/exports
10 * on platforms that require explicit instructions to make symbols public,
11 * or differentiate between exported and imported symbols.
12 *
13 * Win32 compilers use this information, and gcc4 can use it on *nix
14 * to reduce the size of the export symbol table and get faster runtime
15 * linking.
16 *
17 * All declarations of public API should be marked with the PODOFO_API macro.
18 * Separate definitions need not be annotated, even in headers.
19 *
20 * Usage examples:
21 *
22 * class PODOFO_API PdfArray : public PdfDataContainer {
23 * ...
24 * };
25 *
26 * bool PODOFO_API doThatThing();
27 */
28
29// Sanity check, can't compile both shared and static library
30#if defined(PODOFO_SHARED) && defined(PODOFO_STATIC)
31 #error "Both PODOFO_SHARED and PODOFO_STATIC defined!"
32#endif
33
34#ifdef PODOFO_STATIC
35
36#define PODOFO_API
37#define PODOFO_EXPORT
38#define PODOFO_IMPORT
39
40#else // PODOFO_SHARED
41#ifndef PODOFO_SHARED
42#define PODOFO_SHARED
43#endif
44
45#if defined(_MSC_VER)
46 #define PODOFO_EXPORT __declspec(dllexport)
47 #define PODOFO_IMPORT __declspec(dllimport)
48 #define PODOFO_DEPRECATED
49#else
50 // NOTE: In non MSVC compilers https://gcc.gnu.org/wiki/Visibility,
51 // it's not necessary to distinct between exporting and importing
52 // the symbols and for correct working of RTTI features is better
53 // always set default visibility both when compiling and when using
54 // the library. The symbol will not be re-exported by other libraries
55 #define PODOFO_EXPORT __attribute__ ((visibility("default")))
56 #define PODOFO_IMPORT __attribute__ ((visibility("default")))
57 #define PODOFO_DEPRECATED __attribute__((__deprecated__))
58#endif
59
60// If detected, undefine some macros that are defined by Windows
61// headers and that may cause errors when consuming PoDoFo. To
62// avoid this behavior, define PODOFO_WIN32_SKIP_UNDEF_MACROS
63// before including PoDoFo headers.
64#if defined(_WIN32) && !defined(PODOFO_WIN32_SKIP_UNDEF_MACROS)
65#ifdef min
66#undef min
67#endif // min
68
69#ifdef max
70#undef max
71#endif // max
72
73#ifdef GetObject
74#undef GetObject
75#endif // GetObject
76
77#ifdef CreateFont
78#undef CreateFont
79#endif // CreateFont
80
81#ifdef DrawText
82#undef DrawText
83#endif // DrawText
84#endif
85
86#if defined(PODOFO_BUILD)
87#define PODOFO_API PODOFO_EXPORT
88#else
89#define PODOFO_API PODOFO_IMPORT
90#endif
91
92#endif
93
94// Set up some other compiler-specific but not platform-specific macros
95
98#define PODOFO_PRIVATE_FRIEND(identifier)
99
100#ifndef PODOFO_3RDPARTY_INTEROP_ENABLED
106#define PODOFO_3RDPARTY_INTEROP_ENABLED 0
107#endif // PODOFO_3RDPARTY_INTEROP_ENABLED
108
109// Include some useful compatibility defines
110#include "basecompat.h"
111
112// Include the configuration file
113#include "podofo_config.h"
114
115#endif // PODOFO_BASE_DEFS_H