fix macos build with clang 16

Undefined symbols for architecture arm64:
  "o3tl::strong_int<unsigned short, LanguageTypeTag>::strong_int<int>(int, std::__1::enable_if<std::is_integral<int>::value, int>::type)", referenced from:
      sfx2::(anonymous namespace)::SvxInternalLink::Connect(sfx2::SvBaseLink*) in linkmgr2.o
      SfxHTMLParser::GetTableDataOptionsValNum(unsigned int&, o3tl::strong_int<unsigned short, LanguageTypeTag>&, rtl::OUString const&, std::__1::basic_string_view<char16_t, std::__1::char_traits<char16_t>>, SvNumberFormatter&) in sfxhtml.o
      SfxHTMLParser::GetTableDataOptionsValNum(unsigned int&, o3tl::strong_int<unsigned short, LanguageTypeTag>&, rtl::OUString const&, std::__1::basic_string_view<char16_t, std::__1::char_traits<char16_t>>, SvNumberFormatter&) in sfxhtml.o
      SfxHTMLParser::GetTableDataOptionsValNum(unsigned int&, o3tl::strong_int<unsigned short, LanguageTypeTag>&, rtl::OUString const&, std::__1::basic_string_view<char16_t, std::__1::char_traits<char16_t>>, SvNumberFormatter&) in sfxhtml.o
      SfxHTMLParser::GetTableDataOptionsValNum(unsigned int&, o3tl::strong_int<unsigned short, LanguageTypeTag>&, rtl::OUString const&, std::__1::basic_string_view<char16_t, std::__1::char_traits<char16_t>>, SvNumberFormatter&) in sfxhtml.o
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [/Users/noelgrandin/lode/dev/core/sfx2/Library_sfx.mk:20: /Users/noelgrandin/lode/dev/core/instdir/LibreOfficeDev.app/Contents/Frameworks/libsfxlo.dylib] Error 1
make[1]: Target 'build' not remade because of errors.
make: *** [Makefile:296: build] Error 2

Change-Id: Ia8c338a89156e18a1c96630ecad2bccbba7bb745
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173652
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2024-09-19 08:46:50 +02:00 committed by Noel Grandin
parent 984f92ca04
commit 7db1150b2c
2 changed files with 12 additions and 0 deletions

View file

@ -90,10 +90,13 @@ constexpr LanguageType primary(LanguageType lt) { return LanguageType(sal_uInt16
namespace o3tl
{
// when compiling LO on macOS, debug builds will display a linking error
#if !(defined MACOSX && defined __clang__ && __clang_major__ == 16)
// delete "sal_Int16" constructor via specialization: values > 0x7FFF are
// actually used, and unfortunately passed around in the API as signed
// "short", so use this to find all places where casts must be inserted
template<> template<> constexpr strong_int<unsigned short,LanguageTypeTag>::strong_int(short, std::enable_if<std::is_integral<short>::value, int>::type) = delete;
#endif
}
#define LANGUAGE_MASK_PRIMARY 0x03ff

View file

@ -84,6 +84,14 @@ template <typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
struct strong_int
{
public:
// when compiling LO on macOS, debug builds will display a linking error
#if defined MACOSX && defined __clang__ && __clang_major__ == 16
explicit constexpr strong_int(unsigned long long value) : m_value(value) {}
explicit constexpr strong_int(unsigned long value) : m_value(value) {}
explicit constexpr strong_int(long value) : m_value(value) {}
explicit constexpr strong_int(int value) : m_value(value) {}
explicit constexpr strong_int(unsigned int value) : m_value(value) {}
#else
template<typename T> explicit constexpr strong_int(
T value,
typename std::enable_if<std::is_integral<T>::value, int>::type = 0):
@ -95,6 +103,7 @@ public:
&& "out of range");
#endif
}
#endif
strong_int() : m_value(0) {}
explicit constexpr operator UNDERLYING_TYPE() const { return m_value; }