Imported Upstream version 17.19.0
[platform/upstream/libzypp.git] / zypp / APIConfig.h.in
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/APIConfig.h
10  *  \brief      Provides API related macros.
11  */
12 #ifndef ZYPP_APICONFIG_H
13 #define ZYPP_APICONFIG_H
14
15 #include "zypp/base/Easy.h"     // some macros used almost everywhere
16
17 #define LIBZYPP_VERSION_STRING "@VERSION@"
18 #define LIBZYPP_VERSION_MAJOR  @LIBZYPP_MAJOR@
19 #define LIBZYPP_VERSION_MINOR  @LIBZYPP_MINOR@
20 #define LIBZYPP_VERSION_PATCH  @LIBZYPP_PATCH@
21 #define LIBZYPP_SOVERSION      @LIBZYPP_SO_FIRST@
22 #define LIBZYPP_VERSION        @LIBZYPP_NUMVERSION@
23
24 /**
25  * Legacy code we still support.
26  *
27  * Deprecated items we can't drop immediately because YAST/PK still
28  * refer to them or they break binary compatibility, should be
29  * enclosed in `#if LEGACY(#)` where # is either a minor number(<=99),
30  * a soversion [<=9999] or numversion [<=999999].
31  *
32  */
33 #define LEGACY(CL) ( CL < 100 && LIBZYPP_VERSION_MAJOR <= CL ) || ( CL < 10000 && LIBZYPP_SOVERSION <= CL ) || LIBZYPP_VERSION <= CL
34
35 /**
36  * Generic helper definitions for shared library support.
37  *
38  * \see e.g. http://gcc.gnu.org/wiki/Visibility
39  * \code
40  *   extern "C" ZYPP_API void function(int a);
41  *   class ZYPP_API SomeClass
42  *   {
43  *      int c;
44  *      ZYPP_LOCAL void privateMethod();  // Only for use within this DSO
45  *   public:
46  *      Person(int _c) : c(_c) { }
47  *      static void foo(int a);
48  *   };
49  * \endcode
50 };*/
51 #if __GNUC__ >= 4
52   #define ZYPP_DECL_EXPORT __attribute__ ((visibility ("default")))
53   #define ZYPP_DECL_IMPORT __attribute__ ((visibility ("default")))
54   #define ZYPP_DECL_HIDDEN __attribute__ ((visibility ("hidden")))
55 #else
56   #define ZYPP_DECL_EXPORT
57   #define ZYPP_DECL_IMPORT
58   #define ZYPP_DECL_HIDDEN
59 #endif
60
61 #ifdef ZYPP_DLL //defined if zypp is compiled as DLL
62   #define ZYPP_API      ZYPP_DECL_EXPORT
63   #define ZYPP_LOCAL    ZYPP_DECL_HIDDEN
64 #else
65   #define ZYPP_API      ZYPP_DECL_IMPORT
66   #define ZYPP_LOCAL
67 #endif
68
69 /**
70  * The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings
71  * with gcc >= 3.2 when deprecated functions are used.
72  *
73  * For non-inline functions, the macro is used at the very end of the
74  * function declaration, right before the semicolon, unless it's pure
75  * virtual:
76  *
77  * int deprecatedFunc() const ZYPP_DEPRECATED;
78  * virtual int deprecatedPureVirtualFunc() const ZYPP_DEPRECATED = 0;
79  *
80  * Functions which are implemented inline are handled differently:
81  * the ZYPP_DEPRECATED macro is used at the front, right before the
82  * return type, but after "static" or "virtual":
83  *
84  * ZYPP_DEPRECATED void deprecatedFuncA() { .. }
85  * virtual ZYPP_DEPRECATED int deprecatedFuncB() { .. }
86  * static  ZYPP_DEPRECATED bool deprecatedFuncC() { .. }
87  *
88  * You can also mark whole structs or classes as deprecated, by inserting
89  * the ZYPP_DEPRECATED macro after the struct/class keyword, but before
90  * the name of the struct/class:
91  *
92  * class ZYPP_DEPRECATED DeprecatedClass { };
93  * struct ZYPP_DEPRECATED DeprecatedStruct { };
94  *
95  * However, deprecating a struct/class doesn't create a warning for gcc
96  * versions <= 3.3 (haven't tried 3.4 yet).  If you want to deprecate a class,
97  * also deprecate all member functions as well (which will cause warnings).
98  *
99  */
100 #if __GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)
101   #ifndef ZYPP_DEPRECATED
102   #define ZYPP_DEPRECATED __attribute__ ((deprecated))
103   #endif
104 #else
105   #ifndef ZYPP_DEPRECATED
106   #define ZYPP_DEPRECATED
107   #endif
108 #endif
109
110 #endif //ZYPP_APICONFIG_H