PoDoFo 1.2.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
42#ifndef PODOFO_SHARED
43#define PODOFO_SHARED
44#endif
45
46#if defined(_MSC_VER)
47 #define PODOFO_EXPORT __declspec(dllexport)
48 #define PODOFO_IMPORT __declspec(dllimport)
49 #define PODOFO_DEPRECATED
50#else
51 // NOTE: In non MSVC compilers https://gcc.gnu.org/wiki/Visibility,
52 // it's not necessary to distinct between exporting and importing
53 // the symbols and for correct working of RTTI features is better
54 // always set default visibility both when compiling and when using
55 // the library. The symbol will not be re-exported by other libraries
56 #define PODOFO_EXPORT __attribute__ ((visibility("default")))
57 #define PODOFO_IMPORT __attribute__ ((visibility("default")))
58 #define PODOFO_DEPRECATED __attribute__((__deprecated__))
59#endif
60
61#if defined(PODOFO_BUILD)
62#define PODOFO_API PODOFO_EXPORT
63#else
64#define PODOFO_API PODOFO_IMPORT
65#endif
66
67#endif
68
69// If detected, undefine some macros that are defined by Windows
70// headers and that may cause errors when consuming PoDoFo. To
71// avoid this behavior, define PODOFO_WIN32_SKIP_UNDEF_MACROS
72// before including PoDoFo headers.
73#if defined(_WIN32) && !defined(PODOFO_WIN32_SKIP_UNDEF_MACROS)
74#ifdef min
75#undef min
76#endif // min
77
78#ifdef max
79#undef max
80#endif // max
81
82#ifdef GetObject
83#undef GetObject
84#endif // GetObject
85
86#ifdef CreateFont
87#undef CreateFont
88#endif // CreateFont
89
90#ifdef DrawText
91#undef DrawText
92#endif // DrawText
93#endif
94
95// Set up some other compiler-specific but not platform-specific macros
96
98#define PODOFO_PRIVATE_FRIEND(identifier)
99
100#ifndef PODOFO_3RDPARTY_INTEROP_ENABLED
105#define PODOFO_3RDPARTY_INTEROP_ENABLED 0
106#endif // PODOFO_3RDPARTY_INTEROP_ENABLED
107
108// Include some useful compatibility defines
109#include "basecompat.h"
110
111// Include the configuration file
112#include "podofo_config.h"
113
114#endif // PODOFO_BASE_DEFS_H