1 // Copyright 2011-2012 Renato Tegon Forti
2 // Copyright 2014 Renato Tegon Forti, Antony Polukhin.
3 // Copyright 2015-2016, Antony Polukhin.
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt
7 // or copy at http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see http://www.boost.org
11 // MinGW related workaround
12 #define BOOST_DLL_FORCE_ALIAS_INSTANTIATION
14 #include <boost/config.hpp>
15 #include <boost/dll/alias.hpp>
19 #include <boost/shared_ptr.hpp>
20 #include <boost/make_shared.hpp>
21 #include <boost/fusion/container.hpp>
23 #define LIBRARY_API BOOST_SYMBOL_EXPORT
25 extern "C" void LIBRARY_API
say_hello(void);
26 extern "C" float LIBRARY_API
lib_version(void);
27 extern "C" int LIBRARY_API
increment(int);
29 extern "C" int LIBRARY_API integer_g
;
30 extern "C" const int LIBRARY_API const_integer_g
= 777;
33 std::size_t bar(const std::vector
<int>& v
) {
37 std::size_t variable
= 42;
42 // Make sure that aliases have no problems with memory allocations and different types of input parameters
43 namespace namespace1
{ namespace namespace2
{ namespace namespace3
{
45 boost::fusion::vector
<std::vector
<int>, std::vector
<int>, std::vector
<int>, const std::vector
<int>*, std::vector
<int>* >
48 boost::shared_ptr
<do_share_res_t
> do_share(
51 const std::vector
<int>& v3
,
52 const std::vector
<int>* v4
,
58 return boost::make_shared
<do_share_res_t
>(v1
, v2
, v3
, v4
, v5
);
61 std::string
info("I am a std::string from the test_library (Think of me as of 'Hello world'. Long 'Hello world').");
63 int& ref_returning_function() {
71 BOOST_DLL_ALIAS(foo::bar
, foo_bar
)
72 BOOST_DLL_ALIAS(foo::variable
, foo_variable
)
73 BOOST_DLL_ALIAS(namespace1::namespace2::namespace3::do_share
, do_share
)
74 BOOST_DLL_ALIAS(namespace1::namespace2::namespace3::info
, info
)
75 BOOST_DLL_ALIAS(const_integer_g
, const_integer_g_alias
)
76 BOOST_DLL_ALIAS(namespace1::namespace2::namespace3::ref_returning_function
, ref_returning_function
)
84 std::cout
<< "Hello, Boost.Application!" << std::endl
;
87 float lib_version(void)
97 #include <boost/dll/runtime_symbol_info.hpp>
99 boost::filesystem::path
this_module_location_from_itself() {
100 return boost::dll::this_line_location();
103 BOOST_DLL_ALIAS(this_module_location_from_itself
, module_location_from_itself
)
107 int internal_integer_i
= 0xFF0000;
108 extern "C" LIBRARY_API
int& reference_to_internal_integer
;
109 int& reference_to_internal_integer
= internal_integer_i
;
111 #ifndef BOOST_NO_RVALUE_REFERENCES
112 extern "C" LIBRARY_API
int&& rvalue_reference_to_internal_integer
;
113 int&& rvalue_reference_to_internal_integer
= static_cast<int&&>(internal_integer_i
);