drobilla / jalv

A simple fully-featured host for LV2 plugins
http://drobilla.net/software/jalv
ISC License
54 stars 19 forks source link

no viable conversion from 'const std::__1::ctype<char>::char_type' (aka 'const char') to 'QLatin1String #44

Closed yurivict closed 2 years ago

yurivict commented 3 years ago

clang-10 complains about 1.6.6 on FreeBSD 12.2:

/usr/include/c++/v1/__locale:649:27: error: no viable conversion from 'const std::__1::ctype<char>::char_type' (aka 'const char') to 'QLatin1String'
            if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))
                          ^~~~~~
drobilla commented 3 years ago

This gives me no information about where this is triggered in the code. Please (always) paste the complete compiler output.

yurivict commented 3 years ago

Sorry, my bad.

In file included from ../src/jalv_gtkmm2.cpp:25:
In file included from ../../../../../../local/include/gtkmm-2.4/gtkmm/button.h:7:
In file included from ../../../../../../local/include/glibmm-2.4/glibmm/ustring.h:26:
In file included from /usr/include/c++/v1/sstream:173:
In file included from /usr/include/c++/v1/ostream:138:
In file included from /usr/include/c++/v1/ios:215:
/usr/include/c++/v1/__locale:625:16: error: use of undeclared identifier 'isascii'
        return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false;
               ^
/usr/include/c++/v1/__locale:632:22: error: use of undeclared identifier 'isascii'
            *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0;
                     ^
/usr/include/c++/v1/__locale:640:17: error: use of undeclared identifier 'isascii'
            if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))
                ^
/usr/include/c++/v1/__locale:649:19: error: use of undeclared identifier 'isascii'
            if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))
                  ^
4 errors generated.

In file included from ../src/jalv_qt.cpp:53:
In file included from ../../../../../../local/include/qt5/QtCore/QtCore:177:
In file included from ../../../../../../local/include/qt5/QtCore/qrandom.h:45:
In file included from /usr/include/c++/v1/random:1645:
In file included from /usr/include/c++/v1/istream:163:
In file included from /usr/include/c++/v1/ostream:138:
In file included from /usr/include/c++/v1/ios:215:
/usr/include/c++/v1/__locale:625:16: error: use of undeclared identifier 'isascii'; did you mean 'QtPrivate::isAscii'?
        return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false;
               ^
../../../../../../local/include/qt5/QtCore/qstringalgorithms.h:98:59: note: 'QtPrivate::isAscii' declared here
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String s) noexcept;
                                                          ^
In file included from ../src/jalv_qt.cpp:53:
In file included from ../../../../../../local/include/qt5/QtCore/QtCore:177:
In file included from ../../../../../../local/include/qt5/QtCore/qrandom.h:45:
In file included from /usr/include/c++/v1/random:1645:
In file included from /usr/include/c++/v1/istream:163:
In file included from /usr/include/c++/v1/ostream:138:
In file included from /usr/include/c++/v1/ios:215:
/usr/include/c++/v1/__locale:625:24: error: no viable conversion from 'std::__1::ctype<char>::char_type' (aka 'char') to 'QLatin1String'
        return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false;
                       ^~~
../../../../../../local/include/qt5/QtCore/qstring.h:87:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'std::__1::ctype<char>::char_type' (aka 'char') to 'const QLatin1String &' for 1st argument
class QLatin1String
      ^
../../../../../../local/include/qt5/QtCore/qstring.h:87:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'std::__1::ctype<char>::char_type' (aka 'char') to 'QLatin1String &&' for 1st argument
../../../../../../local/include/qt5/QtCore/qstring.h:91:38: note: explicit constructor is not a candidate
    Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) noexcept : m_size(s ? int(strlen(s)) : 0), m_data(s) {}
                                     ^
../../../../../../local/include/qt5/QtCore/qstring.h:95:21: note: explicit constructor is not a candidate
    inline explicit QLatin1String(const QByteArray &s) noexcept : m_size(int(qstrnlen(s.constData(), s.size()))), m_data(s.constData()) {}
                    ^
../../../../../../local/include/qt5/QtCore/qstringalgorithms.h:98:81: note: passing argument to parameter 's' here
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String s) noexcept;
                                                                                ^
In file included from ../src/jalv_qt.cpp:53:
In file included from ../../../../../../local/include/qt5/QtCore/QtCore:177:
In file included from ../../../../../../local/include/qt5/QtCore/qrandom.h:45:
In file included from /usr/include/c++/v1/random:1645:
In file included from /usr/include/c++/v1/istream:163:
In file included from /usr/include/c++/v1/ostream:138:
In file included from /usr/include/c++/v1/ios:215:
/usr/include/c++/v1/__locale:632:22: error: use of undeclared identifier 'isascii'; did you mean 'QtPrivate::isAscii'?
            *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0;
                     ^
../../../../../../local/include/qt5/QtCore/qstringalgorithms.h:98:59: note: 'QtPrivate::isAscii' declared here
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String s) noexcept;
                                                          ^
In file included from ../src/jalv_qt.cpp:53:
In file included from ../../../../../../local/include/qt5/QtCore/QtCore:177:
In file included from ../../../../../../local/include/qt5/QtCore/qrandom.h:45:
In file included from /usr/include/c++/v1/random:1645:
In file included from /usr/include/c++/v1/istream:163:
In file included from /usr/include/c++/v1/ostream:138:
In file included from /usr/include/c++/v1/ios:215:
/usr/include/c++/v1/__locale:632:30: error: no viable conversion from 'const std::__1::ctype<char>::char_type' (aka 'const char') to 'QLatin1String'
            *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0;
                             ^~~~~~
../../../../../../local/include/qt5/QtCore/qstring.h:87:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const std::__1::ctype<char>::char_type' (aka 'const char') to 'const QLatin1String &' for 1st argument
class QLatin1String
      ^
../../../../../../local/include/qt5/QtCore/qstring.h:87:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'const std::__1::ctype<char>::char_type' (aka 'const char') to 'QLatin1String &&' for 1st argument
../../../../../../local/include/qt5/QtCore/qstring.h:91:38: note: explicit constructor is not a candidate
    Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) noexcept : m_size(s ? int(strlen(s)) : 0), m_data(s) {}
                                     ^
../../../../../../local/include/qt5/QtCore/qstring.h:95:21: note: explicit constructor is not a candidate
    inline explicit QLatin1String(const QByteArray &s) noexcept : m_size(int(qstrnlen(s.constData(), s.size()))), m_data(s.constData()) {}
                    ^
../../../../../../local/include/qt5/QtCore/qstringalgorithms.h:98:81: note: passing argument to parameter 's' here
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String s) noexcept;
                                                                                ^
In file included from ../src/jalv_qt.cpp:53:
In file included from ../../../../../../local/include/qt5/QtCore/QtCore:177:
In file included from ../../../../../../local/include/qt5/QtCore/qrandom.h:45:
In file included from /usr/include/c++/v1/random:1645:
In file included from /usr/include/c++/v1/istream:163:
In file included from /usr/include/c++/v1/ostream:138:
In file included from /usr/include/c++/v1/ios:215:
/usr/include/c++/v1/__locale:640:17: error: use of undeclared identifier 'isascii'; did you mean 'QtPrivate::isAscii'?
            if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))
                ^
../../../../../../local/include/qt5/QtCore/qstringalgorithms.h:98:59: note: 'QtPrivate::isAscii' declared here
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String s) noexcept;
                                                          ^
In file included from ../src/jalv_qt.cpp:53:
In file included from ../../../../../../local/include/qt5/QtCore/QtCore:177:
In file included from ../../../../../../local/include/qt5/QtCore/qrandom.h:45:
In file included from /usr/include/c++/v1/random:1645:
In file included from /usr/include/c++/v1/istream:163:
In file included from /usr/include/c++/v1/ostream:138:
In file included from /usr/include/c++/v1/ios:215:
/usr/include/c++/v1/__locale:640:25: error: no viable conversion from 'const std::__1::ctype<char>::char_type' (aka 'const char') to 'QLatin1String'
            if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))
                        ^~~~~~
../../../../../../local/include/qt5/QtCore/qstring.h:87:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const std::__1::ctype<char>::char_type' (aka 'const char') to 'const QLatin1String &' for 1st argument
class QLatin1String
      ^
../../../../../../local/include/qt5/QtCore/qstring.h:87:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'const std::__1::ctype<char>::char_type' (aka 'const char') to 'QLatin1String &&' for 1st argument
../../../../../../local/include/qt5/QtCore/qstring.h:91:38: note: explicit constructor is not a candidate
    Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) noexcept : m_size(s ? int(strlen(s)) : 0), m_data(s) {}
                                     ^
../../../../../../local/include/qt5/QtCore/qstring.h:95:21: note: explicit constructor is not a candidate
    inline explicit QLatin1String(const QByteArray &s) noexcept : m_size(int(qstrnlen(s.constData(), s.size()))), m_data(s.constData()) {}
                    ^
../../../../../../local/include/qt5/QtCore/qstringalgorithms.h:98:81: note: passing argument to parameter 's' here
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String s) noexcept;
                                                                                ^
In file included from ../src/jalv_qt.cpp:53:
In file included from ../../../../../../local/include/qt5/QtCore/QtCore:177:
In file included from ../../../../../../local/include/qt5/QtCore/qrandom.h:45:
In file included from /usr/include/c++/v1/random:1645:
In file included from /usr/include/c++/v1/istream:163:
In file included from /usr/include/c++/v1/ostream:138:
In file included from /usr/include/c++/v1/ios:215:
/usr/include/c++/v1/__locale:649:19: error: use of undeclared identifier 'isascii'; did you mean 'QtPrivate::isAscii'?
            if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))
                  ^
../../../../../../local/include/qt5/QtCore/qstringalgorithms.h:98:59: note: 'QtPrivate::isAscii' declared here
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String s) noexcept;
                                                          ^
In file included from ../src/jalv_qt.cpp:53:
In file included from ../../../../../../local/include/qt5/QtCore/QtCore:177:
In file included from ../../../../../../local/include/qt5/QtCore/qrandom.h:45:
In file included from /usr/include/c++/v1/random:1645:
In file included from /usr/include/c++/v1/istream:163:
In file included from /usr/include/c++/v1/ostream:138:
In file included from /usr/include/c++/v1/ios:215:
/usr/include/c++/v1/__locale:649:27: error: no viable conversion from 'const std::__1::ctype<char>::char_type' (aka 'const char') to 'QLatin1String'
            if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))
                          ^~~~~~
../../../../../../local/include/qt5/QtCore/qstring.h:87:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const std::__1::ctype<char>::char_type' (aka 'const char') to 'const QLatin1String &' for 1st argument
class QLatin1String
      ^
../../../../../../local/include/qt5/QtCore/qstring.h:87:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'const std::__1::ctype<char>::char_type' (aka 'const char') to 'QLatin1String &&' for 1st argument
../../../../../../local/include/qt5/QtCore/qstring.h:91:38: note: explicit constructor is not a candidate
    Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) noexcept : m_size(s ? int(strlen(s)) : 0), m_data(s) {}
                                     ^
../../../../../../local/include/qt5/QtCore/qstring.h:95:21: note: explicit constructor is not a candidate
    inline explicit QLatin1String(const QByteArray &s) noexcept : m_size(int(qstrnlen(s.constData(), s.size()))), m_data(s.constData()) {}
                    ^
../../../../../../local/include/qt5/QtCore/qstringalgorithms.h:98:81: note: passing argument to parameter 's' here
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String s) noexcept;
                                                                                ^
8 errors generated.
drobilla commented 3 years ago

Huh. It seems like your system headers are broken. Specifically, /usr/include/c++/v1/__locale is missing a ctype include.

drobilla commented 2 years ago

jalv_gtkmm2.cpp doesn't need <cctype>, so I don't think jamming an include at the top of the file is appropriate. As far as I can tell, your system headers are broken and the relevant Jalv code is correct.

This should be fixed in libc++, Qt, or perhaps the FreeBSD port as a last resort.

yurivict commented 2 years ago

The problem is triggered by this _POSIX_C_SOURCE: https://github.com/drobilla/jalv/blob/master/src/jalv_internal.h#L20

What does it mean when you use C++11?

I think this gets compiler confused.

drobilla commented 2 years ago

Weird.

What does it mean when you use C++11?

No idea, but ba54d31 should avoid it.

yurivict commented 2 years ago

I think _POSIX_C_SOURCE should be removed.

drobilla commented 2 years ago

...

The code that is defining it - obviously - uses POSIX features that require it to be defined, according to the POSIX specification and in practice on Linux.

drobilla commented 2 years ago

Current master (d2fcfe0) builds fine on FreeBSD 13.0 for me.