1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/APIConfig.h
10 * \brief Provides API related macros.
12 #ifndef ZYPP_APICONFIG_H
13 #define ZYPP_APICONFIG_H
15 #include "zypp/base/Easy.h" // some macros used almost everywhere
18 * Generic helper definitions for shared library support.
20 * \see e.g. http://gcc.gnu.org/wiki/Visibility
22 * extern "C" ZYPP_API void function(int a);
23 * class ZYPP_API SomeClass
26 * ZYPP_LOCAL void privateMethod(); // Only for use within this DSO
28 * Person(int _c) : c(_c) { }
29 * static void foo(int a);
34 #define ZYPP_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
35 #define ZYPP_HELPER_DLL_LOCAL __attribute__ ((visibility ("hidden")))
37 #define ZYPP_HELPER_DLL_EXPORT
38 #define ZYPP_HELPER_DLL_LOCAL
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
50 * The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings
51 * with gcc >= 3.2 when deprecated functions are used.
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
57 * int deprecatedFunc() const ZYPP_DEPRECATED;
58 * virtual int deprecatedPureVirtualFunc() const ZYPP_DEPRECATED = 0;
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":
64 * ZYPP_DEPRECATED void deprecatedFuncA() { .. }
65 * virtual ZYPP_DEPRECATED int deprecatedFuncB() { .. }
66 * static ZYPP_DEPRECATED bool deprecatedFuncC() { .. }
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:
72 * class ZYPP_DEPRECATED DeprecatedClass { };
73 * struct ZYPP_DEPRECATED DeprecatedStruct { };
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).
80 #if __GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)
81 #ifndef ZYPP_DEPRECATED
82 #define ZYPP_DEPRECATED __attribute__ ((deprecated))
85 #ifndef ZYPP_DEPRECATED
86 #define ZYPP_DEPRECATED
90 #endif //ZYPP_APICONFIG_H