Kacper Kasper:
> In RunStyles.cxx there are two instatiations of RunStyles - for int and for ptrdiff_t. The second one is guarded with #if PTRDIFF_MAX != INT_MAX.
> This is problematic because on 32-bit Haiku PTRDIFF_MAX is equal to INT_MAX, but ptrdiff_t is long int. Despite the same size it's a different type and shared object ends up with undefined symbols.
>
> We have a fix in our ports tree [1], but I think this check is broken and should be removed.
The check is required to build with g++ on 32-bit Linux. Here is the error when it is removed:
g++ -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/harfbuzz -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -pthread --std=gnu++17 -DNDEBUG -Os -Wall -pedantic -fPIC -DGTK -DSCI_LEXER -I ./../include -I ./../src -I ./../lexlib -c ./../src/RunStyles.cxx
./../src/RunStyles.cxx:313:27: error: duplicate explicit instantiation of ‘class Scintilla::RunStyles<int, int>’ [-fpermissive]
template class Scintilla::RunStyles<ptrdiff_t, int>;
^~~~~~~~~~~~~~~~~~~~~~~~~
./../src/RunStyles.cxx:314:27: error: duplicate explicit instantiation of ‘class Scintilla::RunStyles<int, char>’ [-fpermissive]
template class Scintilla::RunStyles<ptrdiff_t, char>;
^~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [makefile:96: RunStyles.o] Error 1
A better fix would be to detect if ptrdiff_t and int are different types but I can’t see how to do that with the preprocessor or with templates.
Neil