Skip to content

Commit 464e224

Browse files
authored
Don't export boost_stacktrace_impl_return_nullptr for static build (#186)
Now `boost_stacktrace.lib` provides the symbol `boost_stacktrace_impl_return_nullptr` for static and shared build. For header only library, to make the symbol available **automatically**, the only way AFAIK is to export it. We may also consider provide a configuration macro to opt-out the exported symbol, and user need to manually define the non-exported symbol somewhere in their binaries. Closes #177 .
1 parent 3f79aee commit 464e224

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

include/boost/stacktrace/frame.hpp

+14
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@
2020
#include <boost/stacktrace/detail/frame_decl.hpp>
2121
#include <boost/stacktrace/detail/push_options.h>
2222

23+
#if defined(BOOST_MSVC) && (defined(BOOST_STACKTRACE_INTERNAL_BUILD_LIBS) || !defined(BOOST_STACKTRACE_LINK))
24+
extern "C" {
25+
26+
#if defined(BOOST_STACKTRACE_DYN_LINK)
27+
BOOST_SYMBOL_EXPORT
28+
#elif defined(BOOST_STACKTRACE_LINK)
29+
#else
30+
BOOST_SYMBOL_EXPORT inline
31+
#endif
32+
void* boost_stacktrace_impl_return_nullptr() { return nullptr; }
33+
34+
}
35+
#endif
36+
2337
namespace boost { namespace stacktrace {
2438

2539
/// Comparison operators that provide platform dependant ordering and have O(1) complexity; are Async-Handler-Safe.

include/boost/stacktrace/stacktrace.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@
3737

3838
extern "C" {
3939

40-
//#if defined(BOOST_STACKTRACE_LINK) && defined(BOOST_STACKTRACE_DYN_LINK)
41-
BOOST_SYMBOL_EXPORT
42-
//#endif
43-
inline void* boost_stacktrace_impl_return_nullptr() { return nullptr; }
4440
const char* boost_stacktrace_impl_current_exception_stacktrace();
4541
bool* boost_stacktrace_impl_ref_capture_stacktraces_at_throw();
4642

test/Jamfile.v2

+4
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ test-suite stacktrace_tests
188188
[ run test_void_ptr_cast.cpp ]
189189
[ run test_num_conv.cpp ]
190190

191+
[ run test_from_exception_none.cpp : : : $(LINKSHARED_NOOP) <debug-symbols>on : from_exception_none_noop ]
192+
[ run test_from_exception_none.cpp : : : <define>BOOST_STACKTRACE_USE_NOOP $(NOOP_DEPS) <debug-symbols>on : from_exception_none_noop_ho ]
191193
[ run test_from_exception_none.cpp : : : $(LINKSHARED_BASIC) <debug-symbols>on : from_exception_none_basic ]
192194
[ run test_from_exception_none.cpp : : : $(FORCE_SYMBOL_EXPORT) $(BASIC_DEPS) <debug-symbols>on : from_exception_none_basic_ho ]
193195
[ run test_from_exception_none.cpp : : : $(LINKSHARED_BT) <debug-symbols>on : from_exception_none_bt ]
@@ -197,6 +199,8 @@ test-suite stacktrace_tests
197199
[ run test_from_exception_none.cpp : : : $(LINKSHARED_WIND_CACHED) <debug-symbols>on : from_exception_none_windbg_cached ]
198200
[ run test_from_exception_none.cpp : : : <define>BOOST_STACKTRACE_USE_WINDBG_CACHED $(WICA_DEPS) <debug-symbols>on : from_exception_none_windbg_cached_ho ]
199201

202+
[ run test_from_exception_none.cpp : : : <library>/boost/stacktrace//boost_stacktrace_from_exception $(LINKSHARED_NOOP) <debug-symbols>on : from_exception_disabled_none ]
203+
[ run test_from_exception_none.cpp : : : <library>/boost/stacktrace//boost_stacktrace_from_exception <define>BOOST_STACKTRACE_USE_NOOP $(NOOP_DEPS) : from_exception_disabled_none_ho ]
200204
[ run test_from_exception_none.cpp : : : <library>/boost/stacktrace//boost_stacktrace_from_exception $(LINKSHARED_BASIC) <debug-symbols>on : from_exception_disabled_basic ]
201205
[ run test_from_exception_none.cpp : : : <library>/boost/stacktrace//boost_stacktrace_from_exception $(FORCE_SYMBOL_EXPORT) $(BASIC_DEPS) <debug-symbols>on : from_exception_disabled_basic_ho ]
202206
[ run test_from_exception_none.cpp : : : <library>/boost/stacktrace//boost_stacktrace_from_exception $(LINKSHARED_BT) <debug-symbols>on : from_exception_disabled_bt ]

0 commit comments

Comments
 (0)