Scribus
Open source desktop publishing at your fingertips
scribusapi.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 #ifndef SCRIBUS_API_H
8 #define SCRIBUS_API_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  * Currently, that's win32, but gcc4's facilities for more selective
16  * exports can be tied into this too (see bug #1961).
17  *
18  * Use this macro in the declaration of classes that must be exported
19  * to plug-ins. With current Scribus code, that's most of them.
20  *
21  * Usage examples:
22  *
23  * class SCRIBUS_API PageItem
24  * {
25  * ...
26  * };
27  *
28  * bool SCRIBUS_API doThatThing(void);
29  *
30  * For an exception type that may be thrown across a DSO boundary, you must
31  * use:
32  *
33  * class SCEXCEPTIONAPI(SCRIBUS_API) MyException
34  * {
35  * ...
36  * };
37  *
38  * For information on the gcc visibility support see:
39  * http://gcc.gnu.org/wiki/Visibility
40  * http://people.redhat.com/drepper/dsohowto.pdf
41  *
42  */
43 
44 #ifdef _WIN32
45  #ifdef COMPILE_SCRIBUS_MAIN_APP
46  #define SCRIBUS_API __declspec(dllexport)
47  #else
48  #ifdef COMPILE_PLUGIN_AS_DLL
49  #define SCRIBUS_API __declspec(dllimport)
50  #else
51  #define SCRIBUS_API
52  #endif
53  #endif
54 #else
55  #ifdef HAVE_GCC_SYMBOL_VISIBILITY
56  /* Forces inclusion of a symbol in the symbol table, so
57  software outside the current library / app can use it. */
58  #define SCRIBUS_API __attribute__ ((visibility("default")))
59  /* Within a section exported with SCRIBUS_API, forces a symbol to be
60  private to the library / app. Good for private members. */
61  #define SCRIBUS_LOCAL __attribute__ ((visibility("hidden")))
62  #else
63  #define SCRIBUS_API
64  #define SCRIBUS_LOCAL
65  #endif
66 #endif
67 
68 /* Throwable classes must always be visible on GCC in all binaries */
69 #ifdef WIN32
70  #define SCEXCEPTIONAPI(api) api
71 #elif defined(HAVE_GCC_SYMBOL_VISIBILITY)
72  #define SCEXCEPTIONAPI(api) SCRIBUS_API
73 #else
74  #define SCEXCEPTIONAPI(api)
75 #endif
76 
77 #endif