2 * Cross platform defines for exporting symbols from shared libraries
4 * Wireshark - Network traffic analyzer
5 * By Balint Reczey <balint@balintreczey.hu>
6 * Copyright 2013 Balint Reczey
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 /** Reset symbol export behavior.
24 * If you {un}define WS_BUILD_DLL on the fly you'll have to define this
27 #ifdef RESET_SYMBOL_EXPORT
29 #ifdef SYMBOL_EXPORT_H
30 #undef SYMBOL_EXPORT_H
37 #ifdef WS_DLL_PUBLIC_NOEXTERN
38 #undef WS_DLL_PUBLIC_NOEXTERN
45 #endif /* RESET_SYMBOL_EXPORT */
47 #ifndef SYMBOL_EXPORT_H
48 #define SYMBOL_EXPORT_H
50 /* Originally copied from GCC Wiki at http://gcc.gnu.org/wiki/Visibility */
51 #if defined _WIN32 || defined __CYGWIN__
54 #define WS_DLL_PUBLIC __attribute__ ((dllexport))
55 #else /* ! __GNUC__ */
56 #define WS_DLL_PUBLIC __declspec(dllexport) /* Note: actually gcc seems to also support this syntax. */
58 #else /* WS_BUILD_DLL */
60 #define WS_DLL_PUBLIC __attribute__ ((dllimport))
61 #elif ! (defined ENABLE_STATIC) /* ! __GNUC__ */
62 #define WS_DLL_PUBLIC __declspec(dllimport) /* Note: actually gcc seems to also support this syntax. */
63 #else /* ! __GNUC__ && ENABLE_STATIC */
66 #endif /* WS_BUILD_DLL */
67 #define WS_DLL_PUBLIC_NOEXTERN WS_DLL_PUBLIC
69 #else /* defined _WIN32 || defined __CYGWIN__ */
71 #define WS_DLL_PUBLIC __attribute__ ((visibility ("default"))) extern
72 #define WS_DLL_PUBLIC_NOEXTERN __attribute__ ((visibility ("default")))
73 #define WS_DLL_LOCAL __attribute__ ((visibility ("hidden")))
74 #else /* ! __GNUC__ >= 4 */
75 #define WS_DLL_PUBLIC extern
76 #define WS_DLL_PUBLIC_NOEXTERN
78 #endif /* __GNUC__ >= 4 */
81 #endif /* SYMBOL_EXPORT_H */