mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-07 08:31:16 +00:00
Fix symbol visibility on Linux when compiling with -fvisibility=hidden (#1535)
Make FMT_API symbols use the default visibility on non-Windows platforms. Otherwise, one cannot use the generated fmt library when compiling globally with -fvisibility=hidden. Fixes compile errors like: ``` ../3rdParty/fmt/include/fmt/core.h:757: error: undefined reference to 'fmt::v6::internal::assert_fail(char const*, int, char const*)' ``` Note that the symbol exists, but is local: ``` $ nm -C libfmtd.so.6.1.3 | grep assert_fail U __assert_fail 0000000000233ffa t fmt::v6::internal::assert_fail(char const*, int, char const*) ``` With this patch, the compile error is gone and the symbol is properly exported: ``` $ nm -a bin/libfmtd.so -C | grep assert_fail U __assert_fail 00000000002366ba T fmt::v6::internal::assert_fail(char const*, int, char const*) ``` Change-Id: I96054e622d9a2ae81907e1b01a1033e629767a91
This commit is contained in:
parent
f499b393d1
commit
314e15001f
@ -185,11 +185,20 @@
|
||||
# define FMT_CLASS_API
|
||||
#endif
|
||||
#ifndef FMT_API
|
||||
# define FMT_API
|
||||
# if FMT_GCC_VERSION || FMT_CLANG_VERSION
|
||||
# define FMT_API __attribute__((visibility("default")))
|
||||
# define FMT_EXTERN_TEMPLATE_API FMT_API
|
||||
# define FMT_INSTANTIATION_DEF_API
|
||||
# else
|
||||
# define FMT_API
|
||||
# endif
|
||||
#endif
|
||||
#ifndef FMT_EXTERN_TEMPLATE_API
|
||||
# define FMT_EXTERN_TEMPLATE_API
|
||||
#endif
|
||||
#ifndef FMT_INSTANTIATION_DEF_API
|
||||
# define FMT_INSTANTIATION_DEF_API FMT_API
|
||||
#endif
|
||||
|
||||
#ifndef FMT_HEADER_ONLY
|
||||
# define FMT_EXTERN extern
|
||||
|
@ -121,7 +121,7 @@ template FMT_API char* internal::sprintf_format(long double,
|
||||
internal::buffer<char>&,
|
||||
sprintf_specs);
|
||||
|
||||
template struct FMT_API internal::basic_data<void>;
|
||||
template struct FMT_INSTANTIATION_DEF_API internal::basic_data<void>;
|
||||
|
||||
// Workaround a bug in MSVC2013 that prevents instantiation of format_float.
|
||||
int (*instantiate_format_float)(double, int, internal::float_specs,
|
||||
|
Loading…
Reference in New Issue
Block a user