Skip to content

Commit bd70cb2

Browse files
committed
visibility_control
1 parent 50c26df commit bd70cb2

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#ifndef PKGNAME__VISIBILITY_CONTROL_H_
2+
#define PKGNAME__VISIBILITY_CONTROL_H_
3+
4+
// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
5+
// https://gcc.gnu.org/wiki/Visibility
6+
7+
#if defined _WIN32 || defined __CYGWIN__
8+
#ifdef __GNUC__
9+
#define PKGNAME_EXPORT __attribute__ ((dllexport))
10+
#define PKGNAME_IMPORT __attribute__ ((dllimport))
11+
#else
12+
#define PKGNAME_EXPORT __declspec(dllexport)
13+
#define PKGNAME_IMPORT __declspec(dllimport)
14+
#endif
15+
#ifdef PKGNAME_BUILDING_LIBRARY
16+
#define PKGNAME_PUBLIC PKGNAME_EXPORT
17+
#else
18+
#define PKGNAME_PUBLIC PKGNAME_IMPORT
19+
#endif
20+
#define PKGNAME_PUBLIC_TYPE PKGNAME_PUBLIC
21+
#define PKGNAME_LOCAL
22+
#else
23+
#define PKGNAME_EXPORT __attribute__ ((visibility("default")))
24+
#define PKGNAME_IMPORT
25+
#if __GNUC__ >= 4
26+
#define PKGNAME_PUBLIC __attribute__ ((visibility("default")))
27+
#define PKGNAME_LOCAL __attribute__ ((visibility("hidden")))
28+
#else
29+
#define PKGNAME_PUBLIC
30+
#define PKGNAME_LOCAL
31+
#endif
32+
#define PKGNAME_PUBLIC_TYPE
33+
#endif
34+
35+
#endif // PKGNAME__VISIBILITY_CONTROL_H_

0 commit comments

Comments
 (0)