hpp-util  4.9.0
Debugging tools for the HPP project.
portability.hh
Go to the documentation of this file.
1 // Copyright (C) 2008, 2009 by Thomas Moulard, CNRS.
2 //
3 // This file is part of the hpp-util.
4 //
5 // This software is provided "as is" without warranty of any kind,
6 // either expressed or implied, including but not limited to the
7 // implied warranties of fitness for a particular purpose.
8 //
9 // See the COPYING file for more information.
10 
11 #ifndef HPP_PORTABILITY_HH
12 # define HPP_PORTABILITY_HH
13 
14 // Handle portable symbol export.
15 // Defining manually which symbol should be exported is required
16 // under Windows whether MinGW or MSVC is used.
17 //
18 // The headers then have to be able to work in two different modes:
19 // - dllexport when one is building the library,
20 // - dllimport for clients using the library.
21 //
22 // On Linux, set the visibility accordingly. If C++ symbol visibility
23 // is handled by the compiler, see: http://gcc.gnu.org/wiki/Visibility
24 # if defined _WIN32 || defined __CYGWIN__
25 // On Microsoft Windows, use dllimport and dllexport to tag symbols.
26 # define HPP_DLLIMPORT __declspec(dllimport)
27 # define HPP_DLLEXPORT __declspec(dllexport)
28 # define HPP_DLLLOCAL
29 # else
30 // On Linux, for GCC >= 4, tag symbols using GCC extension.
31 # if __GNUC__ >= 4
32 # define HPP_DLLIMPORT __attribute__ ((visibility("default")))
33 # define HPP_DLLEXPORT __attribute__ ((visibility("default")))
34 # define HPP_DLLLOCAL __attribute__ ((visibility("hidden")))
35 # else
36 // Otherwise (GCC < 4 or another compiler is used), export everything.
37 # define HPP_DLLIMPORT
38 # define HPP_DLLEXPORT
39 # define HPP_DLLLOCAL
40 # endif // __GNUC__ >= 4
41 # endif // defined _WIN32 || defined __CYGWIN__
42 #endif