JKQtExtras
a library of useful Qt widgets and tools
jkqtextras_imexport.h
1 /*
2  Copyright (c) 2008-2020 Jan W. Krieger (<jan@jkrieger.de>)
3 
4  This software is free software: you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License (LGPL) as published by
6  the Free Software Foundation, either version 2.1 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Lesser General Public License (LGPL) for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License (LGPL)
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef JKQTEXTRAS_IMPORT_H
19 #define JKQTEXTRAS_IMPORT_H
20 
21 
22 
23 
24 /*! \def JKQTEXTRAS_LIB_EXPORT
25  \ingroup JKQtExtras
26 
27  This define allows to export functions and classes from the jkqtcommon-library when building a dynamic/shared library.
28  Usage is as follows:
29  \code
30  #include "jkqtextras/jkqtextras_imexport.h.h"
31 
32  class JKQTEXTRAS_LIB_EXPORT exportedClassName {
33  ...
34  };
35 
36  JKQTEXTRAS_LIB_EXPORT void exportedFunctionName();
37  \endcode
38 
39  These macros append the appropriate \c __declspec(dllexport) and \c __declspec(dllimport)
40  to the function/class body and thus tell windows compilers to export these sysmbols from
41  the shared library, or import them from a shared library.
42 
43  Note that these attributes are only necessary on windows systems!
44 
45  These macros are controlled by two other macros:
46  - \c JKQTEXTRAS_LIB_IN_DLL declares that the application should link against a shared version of
47  JKQtExtras, i.e. \c JKQtExtrasSharedLib_XYZ .
48  This needs to be defined while compiling the library and while compiling
49  any application linking against \c JKQtExtrasSharedLib_XYZ.
50  - \c JKQTEXTRAS_LIB_EXPORT_LIBRARY is only defined while compiling JKQtExtras into \c JKQtExtrasSharedLib_XYZ
51  and ensures thet the symbols are exported. If it is not defined (e.g. while
52  compiling an application), the symbols are imported
53  .
54 
55  */
56 
57 /*! \def JKQTEXTRAS_LIB_IN_DLL
58  \ingroup JKQtExtras
59  \brief declares that the application should link against a shared version of
60  JKQtExtras, i.e. \c JKQtExtrasSharedLib_XYZ .
61  This needs to be defined while compiling the library and while compiling
62  any application linking against \c JKQtExtrasSharedLib_XYZ.
63 */
64 
65 /*! \def JKQTEXTRAS_LIB_EXPORT_LIBRARY
66  \ingroup JKQtExtras
67  \brief is only defined while compiling JKQtExtras into \c JKQtExtrasSharedLib_XYZ
68  and ensures thet the symbols are exported. If it is not defined (e.g. while
69  compiling an application), the symbols are imported
70 */
71 
72 # ifndef __WINDOWS__
73 # if defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)
74 # define __WINDOWS__
75 # endif
76 # endif
77 
78 #ifdef __WINDOWS__
79 # ifdef JKQTEXTRAS_LIB_IN_DLL
80 # ifndef JKQTEXTRAS_LIB_EXPORT
81 # ifdef JKQTEXTRAS_LIB_EXPORT_LIBRARY
82  /* We are building this library */
83 # define JKQTEXTRAS_LIB_EXPORT __declspec(dllexport)
84 # else
85  /* We are using this library */
86 # define JKQTEXTRAS_LIB_EXPORT __declspec(dllimport)
87 # endif
88 # endif
89 # else
90 # ifndef JKQTEXTRAS_LIB_EXPORT
91 # define JKQTEXTRAS_LIB_EXPORT
92 # endif
93 # endif
94 #else
95 # define JKQTEXTRAS_LIB_EXPORT
96 #endif
97 
98 
99 
100 
101 
102 
103 
104 #endif // JKQTEXTRAS_IMPORT_H
105