HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SYS_Visibility.h
Go to the documentation of this file.
1 //
2 // This file is intended to be included in each library-specific API file.
3 // For example, in a hypthetical LIB_API.h:
4 //
5 /*
6 #include <SYS/SYS_Visibility.h>
7 #ifdef LIB_EXPORTS
8 #define LIB_API SYS_VISIBILITY_EXPORT
9 #define LIB_API_TMPL SYS_VISIBILITY_EXPORT_TMPL
10 #define LIB_API_TINST SYS_VISIBILITY_EXPORT_TINST
11 #else
12 #define LIB_API SYS_VISIBILITY_IMPORT
13 #define LIB_API_TMPL SYS_VISIBILITY_IMPORT_TMPL
14 #define LIB_API_TINST SYS_VISIBILITY_IMPORT_TINST
15 #endif
16 */
17 // LIB_API should be used for classes, functions or global variables that need
18 // to be visible by external users of that library. LIB_API_TINST is a special
19 // case for template instantiations, which require an export flag on Windows,
20 // clang and gcc 4.7 or later. They're not required when building with gcc 4.6
21 // and older, since they inherit the visibility from the template class/function
22 // they're instantiated from.
23 // LIB_API_TMPL is required for types which are used as template arguments in
24 // gcc 4.7 and later. Otherwise derived types will not be exported, since all
25 // dependent types need to be visible for the final type to be exported.
26 
27 #ifndef __SYS_Visibility_h__
28 #define __SYS_Visibility_h__
29 
30 #include "SYS_Compiler.h"
31 
32 #if !defined(MAKING_STATIC)
33 # if defined(WIN32)
34 # define SYS_VISIBILITY_EXPORT __declspec(dllexport)
35 # define SYS_VISIBILITY_IMPORT __declspec(dllimport)
36 # define SYS_VISIBILITY_EXPORT_TINST SYS_VISIBILITY_EXPORT
37 # define SYS_VISIBILITY_IMPORT_TINST SYS_VISIBILITY_IMPORT
38 # elif (SYS_IS_CLANG_GE(3, 3) || SYS_IS_GCC_GE(4, 7))
39  // As of clang 3.3 and gcc 4.7, template instantiations do *not* inherit
40  // the visibility attribute.
41  // (See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51930)
42 # define SYS_VISIBILITY_EXPORT __attribute__((visibility("default")))
43 # define SYS_VISIBILITY_IMPORT __attribute__((visibility("default")))
44 # define SYS_VISIBILITY_EXPORT_TMPL SYS_VISIBILITY_EXPORT
45 # define SYS_VISIBILITY_IMPORT_TMPL SYS_VISIBILITY_IMPORT
46 # define SYS_VISIBILITY_EXPORT_TINST SYS_VISIBILITY_EXPORT
47 # define SYS_VISIBILITY_IMPORT_TINST SYS_VISIBILITY_IMPORT
48 # elif SYS_IS_GCC_GE(4, 2)
49 # define SYS_VISIBILITY_EXPORT __attribute__((visibility("default")))
50 # define SYS_VISIBILITY_IMPORT __attribute__((visibility("default")))
51 # endif
52 #endif
53 
54 #ifndef SYS_VISIBILITY_EXPORT
55 # define SYS_VISIBILITY_EXPORT
56 #endif
57 
58 #ifndef SYS_VISIBILITY_IMPORT
59 # define SYS_VISIBILITY_IMPORT
60 #endif
61 
62 #ifndef SYS_VISIBILITY_EXPORT_TMPL
63 # define SYS_VISIBILITY_EXPORT_TMPL
64 #endif
65 
66 #ifndef SYS_VISIBILITY_IMPORT_TMPL
67 # define SYS_VISIBILITY_IMPORT_TMPL
68 #endif
69 
70 #ifndef SYS_VISIBILITY_EXPORT_TINST
71 # define SYS_VISIBILITY_EXPORT_TINST
72 #endif
73 
74 #ifndef SYS_VISIBILITY_IMPORT_TINST
75 # define SYS_VISIBILITY_IMPORT_TINST
76 #endif
77 
78 #endif