Menu

#2396 StringList.h:33:88: error: ‘ptrdiff_t’ has not been declared | Compile fails on flatpak

Bug
closed-fixed
nobody
5
2023-09-22
2023-08-01
No
g++  --std=c++17 -DGTK -DPIXMAP_PATH=\"/app/share/pixmaps\" -DSYSCONF_PATH=\"/app/share/scite\" -DNDEBUG -I ./../../lexilla/include  -I ./../../lexilla/access -I ./../../scintilla/include -I ./../src -I./../lua/src -Wall -pedantic -Wextra -Wno-misleading-indentation -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/atk-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/at-spi2-atk/2.0 -I/usr/include/blkid -I/usr/include/at-spi-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/pixman-1 -I/usr/include/libmount -pthread -I/usr/include/fribidi -I/usr/include/libpng16 -O3 -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer  -c ./../src/StringList.cxx -o StringList.o
g++  --std=c++17 -DGTK -DPIXMAP_PATH=\"/app/share/pixmaps\" -DSYSCONF_PATH=\"/app/share/scite\" -DNDEBUG -I ./../../lexilla/include  -I ./../../lexilla/access -I ./../../scintilla/include -I ./../src -I./../lua/src -Wall -pedantic -Wextra -Wno-misleading-indentation -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/atk-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/at-spi2-atk/2.0 -I/usr/include/blkid -I/usr/include/at-spi-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/pixman-1 -I/usr/include/libmount -pthread -I/usr/include/fribidi -I/usr/include/libpng16 -O3 -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer  -c ./../src/StyleDefinition.cxx -o StyleDefinition.o
In file included from ./../src/StringList.cxx:22:
./../src/StringList.h:33:88: error: ptrdiff_t has not been declared
   33 |                                    bool ignoreCase, const std::string &wordCharacters, ptrdiff_t wordIndex);
      |                                                                                        ^~~~~~~~~
./../src/StringList.cxx:155:80: error: ptrdiff_t has not been declared
  155 |                      const char *wordStart, const std::string &wordCharacters, ptrdiff_t wordIndex, Compare comp) {
      |                                                                                ^~~~~~~~~
./../src/StringList.cxx:180:133: error: ptrdiff_t has not been declared
  180 | std::string StringList::GetNearestWord(const char *wordStart, size_t searchLen, bool ignoreCase, const std::string &wordCharacters, ptrdiff_t wordIndex) {
      |                                                                                                                                     ^~~~~~~~~
make: *** [makefile:108: StringList.o] Error 1
make: *** Waiting for unfinished jobs....
Error: module SciTE: Child process exited with code 2

Discussion

  • Asif Ali Rizvan

    Asif Ali Rizvan - 2023-08-01

    It's scite537.tgz version 5.3.7 compile fails on flatpak

     
  • Chris Mayo

    Chris Mayo - 2023-08-01

    Fixed for me by:

    --- a/src/StringList.cxx
    +++ b/src/StringList.cxx
    @@ -10,6 +10,7 @@
     #include <cstring>
    
     #include <tuple>
    +#include <stddef.h>
     #include <string>
     #include <string_view>
     #include <vector>
    

    GCC 12.3.1, Gentoo Linux

     

    Last edit: Chris Mayo 2023-08-01
  • rdipardo

    rdipardo - 2023-08-01

    Reproducible.

    g++ (Debian 12.2.0-14) 12.2.0
    

    Simply qualifying the type name with the std:: namespace appears to work as well.

    diff -r 431b8fadbea6 src/StringList.cxx
    --- a/src/StringList.cxx    Fri Jul 28 08:04:10 2023 +1000
    +++ b/src/StringList.cxx    Tue Aug 01 16:55:43 2023 -0400
    @@ -152,7 +152,7 @@
    
     template<typename Compare>
     std::string GetMatch(std::vector<char *>::iterator start, std::vector<char *>::iterator end,
    
    -            const char *wordStart, const std::string &wordCharacters, ptrdiff_t wordIndex, Compare comp) {
    +            const char *wordStart, const std::string &wordCharacters, std::ptrdiff_t wordIndex, Compare comp) {
        std::vector<char *>::iterator elem = std::lower_bound(start, end, wordStart, comp);
        if (!comp(wordStart, *elem) && !comp(*elem, wordStart)) {
            // Found a matching element, now move forward wordIndex matching elements
    @@ -177,7 +177,7 @@
      * The length of the word to compare is passed too.
      * Letter case can be ignored or preserved.
      */
    -std::string StringList::GetNearestWord(const char *wordStart, size_t searchLen, bool ignoreCase, const std::string &wordCharacters, ptrdiff_t wordIndex) {
    +std::string StringList::GetNearestWord(const char *wordStart, size_t searchLen, bool ignoreCase, const std::string &wordCharacters, std::ptrdiff_t wordIndex) {
        if (words.empty())
            return std::string();
        SortIfNeeded(ignoreCase);
    diff -r 431b8fadbea6 src/StringList.h
    --- a/src/StringList.h  Fri Jul 28 08:04:10 2023 +1000
    +++ b/src/StringList.h  Tue Aug 01 16:55:43 2023 -0400
    @@ -30,7 +30,7 @@
        void Set(const char *s);
        void Set(const std::vector<char> &data);
        std::string GetNearestWord(const char *wordStart, size_t searchLen,
    -                  bool ignoreCase, const std::string &wordCharacters, ptrdiff_t wordIndex);
    +                  bool ignoreCase, const std::string &wordCharacters, std::ptrdiff_t wordIndex);
        std::string GetNearestWords(const char *wordStart, size_t searchLen,
                        bool ignoreCase, char otherSeparator='\0', bool exactLen=false);
     };
    
     
  • Neil Hodgson

    Neil Hodgson - 2023-08-01

    5.3.7 compiles OK with g++ (GCC) 13.1.1 20230614 (Red Hat 13.1.1-4) on Fedora 38.

    Added equivalent #include <cstddef> with [120792].

    ptrdiff_t is used in other files so its better not to std:: qualify in just one place.

     

    Related

    Commit: [120792]

  • Neil Hodgson

    Neil Hodgson - 2023-08-01
    • labels: --> SciTE, linux
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2023-09-22
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB