From db63b6316586873ae1fd13318787dca586026645 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 19 Oct 2025 23:40:08 +0200 Subject: support ptrdiff_t if it has the same storage size as int, but does *not* alias it * This is the case e.g. on NetBSD 10 for ARMv6 where Sci::Position == ptrdiff_t == long int, but obviously for other platforms as well, where it causes "invalid conversion" and "undefined symbol" errors. Scintilla was testing for aliasability by comparing the storage size with sizeof() or PTRDIFF_MAX == INT_MAX at the preprocessor level. This was fundamentally flawed. * In LineVector::InsertLines() we are now using the C++17 construct std::is_convertible_v instead. * We need RunStyles as well on the affected platforms. This is impossible to test for in a constant expression that can be used with the preprocessor. Also, it's not possible to conditionally instantiate templates. We tried to instantiate RunStyles for all scalar types that could be behind ptrdiff_t, but it was causing warnings on MSVC. Implicitly instantiating RunStyles would be possible, but is not desired. Therefore as a workaround, you can now define the PTRDIFF_DOESNT_ALIAS_INT macro when invoking the build system, to force instantiating RunStyles. When writing portable applications, you may have to use a compile-time check for checking aliasability of ptrdiff_t and int in order to define PTRDIFF_DOESNT_ALIAS_INT. --- doc/ScintillaDoc.html | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'doc/ScintillaDoc.html') diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 5c92043cc..82829a947 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -10529,6 +10529,13 @@ EM_SETTARGETDEVICE DISABLE_D2D (Win32) Build Scintilla without Direct2D/DirectWrite. + + + PTRDIFF_DOESNT_ALIAS_INT + Define if ptrdiff_t* does not alias int*. + This is detected automatically, but the check may be unreliable. + Try to define this symbol in case of errors about undefined symbols. + -- cgit v1.2.3