Skip to content

Commit 0b026dc

Browse files
committed
Apply GCC export limiting patch from Niall Douglas s_sourceforge-at-nedprod.com
[SVN r25271]
1 parent 3ba268e commit 0b026dc

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

include/boost/python/detail/config.hpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,22 @@
7171
# define BOOST_PYTHON_NO_TEMPLATE_EXPORT
7272
#endif
7373

74-
#if defined(BOOST_PYTHON_DYNAMIC_LIB) && (defined(_WIN32) || defined(__CYGWIN__))
75-
# if defined(BOOST_PYTHON_SOURCE)
76-
# define BOOST_PYTHON_DECL __declspec(dllexport)
77-
# define BOOST_PYTHON_BUILD_DLL
78-
# else
79-
# define BOOST_PYTHON_DECL __declspec(dllimport)
74+
#if defined(BOOST_PYTHON_DYNAMIC_LIB)
75+
# if (defined(_WIN32) || defined(__CYGWIN__))
76+
# if defined(BOOST_PYTHON_SOURCE)
77+
# define BOOST_PYTHON_DECL __declspec(dllexport)
78+
# define BOOST_PYTHON_BUILD_DLL
79+
# else
80+
# define BOOST_PYTHON_DECL __declspec(dllimport)
81+
# endif
82+
# elif (defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >=5)
83+
# if defined(BOOST_PYTHON_SOURCE)
84+
# define BOOST_PYTHON_DECL __attribute__ ((visibility("default")))
85+
# define BOOST_PYTHON_BUILD_DLL
86+
# define BOOST_PYTHON_NODECL_DECLARATIONS
87+
# else
88+
# define BOOST_PYTHON_DECL
89+
# endif
8090
# endif
8191

8292
// MinGW, at least, has some problems exporting template instantiations

include/boost/python/module_init.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ extern "C" \
4242
} \
4343
void init_module_##name()
4444

45+
# elif (defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >=5)
46+
47+
# define BOOST_PYTHON_MODULE_INIT(name) \
48+
void init_module_##name(); \
49+
extern "C" __attribute__ ((visibility("default"))) void init##name() \
50+
{ \
51+
boost::python::detail::init_module(#name, &init_module_##name); \
52+
} \
53+
void init_module_##name()
54+
4555
# else
4656

4757
# define BOOST_PYTHON_MODULE_INIT(name) \

include/boost/python/object/instance.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111

1212
namespace boost { namespace python
1313
{
14+
#ifdef BOOST_PYTHON_NODECL_DECLARATIONS
15+
// Only declaring with BOOST_PYTHON_DECL makes no sense on GCC
16+
struct instance_holder;
17+
#else
1418
struct BOOST_PYTHON_DECL instance_holder;
19+
#endif
1520
}} // namespace boost::python
1621

1722
namespace boost { namespace python { namespace objects {

0 commit comments

Comments
 (0)