Merge pull request #23 from openSUSE/drop_package_manager
[platform/upstream/libzypp.git] / zypp / APIConfig.h
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 /**
18  * Generic helper definitions for shared library support.
19  *
20  * \see e.g. http://gcc.gnu.org/wiki/Visibility
21  * \code
22  *   extern "C" ZYPP_API void function(int a);
23  *   class ZYPP_API SomeClass
24  *   {
25  *      int c;
26  *      ZYPP_LOCAL void privateMethod();  // Only for use within this DSO
27  *   public:
28  *      Person(int _c) : c(_c) { }
29  *      static void foo(int a);
30  *   };
31  * \endcode
32 };*/
33 #if __GNUC__ >= 4
34   #define ZYPP_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
35   #define ZYPP_HELPER_DLL_LOCAL  __attribute__ ((visibility ("hidden")))
36 #else
37   #define ZYPP_HELPER_DLL_EXPORT
38   #define ZYPP_HELPER_DLL_LOCAL
39 #endif
40
41 #ifdef ZYPP_DLL //defined if zypp is compiled as DLL
42   #define ZYPP_API      ZYPP_HELPER_DLL_EXPORT
43   #define ZYPP_LOCAL    ZYPP_HELPER_DLL_LOCAL
44 #else
45   #define ZYPP_API
46   #define ZYPP_LOCAL
47 #endif
48
49 /**
50  * The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings
51  * with gcc >= 3.2 when deprecated functions are used.
52  *
53  * For non-inline functions, the macro is used at the very end of the
54  * function declaration, right before the semicolon, unless it's pure
55  * virtual:
56  *
57  * int deprecatedFunc() const ZYPP_DEPRECATED;
58  * virtual int deprecatedPureVirtualFunc() const ZYPP_DEPRECATED = 0;
59  *
60  * Functions which are implemented inline are handled differently:
61  * the ZYPP_DEPRECATED macro is used at the front, right before the
62  * return type, but after "static" or "virtual":
63  *
64  * ZYPP_DEPRECATED void deprecatedFuncA() { .. }
65  * virtual ZYPP_DEPRECATED int deprecatedFuncB() { .. }
66  * static  ZYPP_DEPRECATED bool deprecatedFuncC() { .. }
67  *
68  * You can also mark whole structs or classes as deprecated, by inserting
69  * the ZYPP_DEPRECATED macro after the struct/class keyword, but before
70  * the name of the struct/class:
71  *
72  * class ZYPP_DEPRECATED DeprecatedClass { };
73  * struct ZYPP_DEPRECATED DeprecatedStruct { };
74  *
75  * However, deprecating a struct/class doesn't create a warning for gcc
76  * versions <= 3.3 (haven't tried 3.4 yet).  If you want to deprecate a class,
77  * also deprecate all member functions as well (which will cause warnings).
78  *
79  */
80 #if __GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)
81   #ifndef ZYPP_DEPRECATED
82   #define ZYPP_DEPRECATED __attribute__ ((deprecated))
83   #endif
84 #else
85   #ifndef ZYPP_DEPRECATED
86   #define ZYPP_DEPRECATED
87   #endif
88 #endif
89
90 #endif //ZYPP_APICONFIG_H