lxqt-panel
lxqt-panel copied to clipboard
lxqt-panel 2.2.2 fails to build with C++20
Expected Behavior
It should compile with C++20.
Current Behavior
Build fails with the following compiler error.
plugin-statusnotifier/sniasync.h:90:99: error: no type named 'argument_type' in 'std::function<void (ToolTip)>'
90 | finished(qdbus_cast<typename std::function<typename call_signature<F>::type>::argument_type>(reply.value()));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
plugin-statusnotifier/sniasync.h:85:17: note: while substituting into a lambda expression here
85 | [this, finished, name] (QDBusPendingCallWatcher * call)
| ^
plugin-statusnotifier/statusnotifierbutton.cpp:281:16: note: in instantiation of function template specialization 'SniAsync::propertyGetAsync<(lambda at plugin-statusnotifier/statusnotifierbutton.cpp:281:59)>' requested here
281 | interface->propertyGetAsync(QLatin1String("ToolTip"), [this] (ToolTip tooltip) {
| ^
Possible Solution
╮( ̄▽ ̄"")╭
Steps to Reproduce (for bugs)
- Build with cmake.
Context
System Information
- LXQt Version: 2.2.0
- Distribution & Version: Termux
- Qt Version: 6.9.1
- liblxqt Version: 2.2.0
You have lxqt-build-tools 2.2.1 ?
You have
lxqt-build-tools2.2.1 ?
Yes.
Here it builds fine but I see a lot of warnings warning: array subscript
inlined from ‘ToolTip StatusNotifierItemAdaptor::toolTip() const’ at /tmp/makepkg/lxqt-panel-git/src/build/plugin-statusnotifier/statusnotifieritemadaptor.cpp:123:66:
/usr/include/c++/15.1.1/bits/move.h:190:11: warning: array subscript 6 is outside array bounds of ‘QVariant [1]’ [-Warray-bounds=]
190 | _Tp __old_val = std::move(__obj);
@tsujan ?
I think the -std=c++20 compiler flag is coming from Qt 6.9.1. It is in every AutogenInfo.json and build.ninja files in the build directory of lxqt-panel.
The build issue happens with lxqt-panel 2.2.1 which compiled fine when it was released.
The standard is set in lxqt-build-tools-2.2.1 (https://github.com/lxqt/lxqt-build-tools/commit/1dc654a8836cc69139342f454f09aadb3da7a1be), and it builds OK for me with Qt 6.10 as well, using gcc-15.1.0
From the full build log at https://github.com/termux/termux-packages/issues/25144 I see it's using clang, building for aarch64.
Wonder if there's something clang-specific going on there?
Here building with
export CC=clang
export CXX=clang++
works fine, only some warnings about warning: 'mimeTypes' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] can be seen.
@Biswa96 Check whether you treat warnings as errors when compiling. We know about those warnings: https://github.com/lxqt/lxqt-panel/issues/2253#issuecomment-2950792099
There in no -Werror and the compiler error is different from that issue. I can not figure out where C++20 is set. Also, std::function::argument_type was removed in C++20.
Would it be possible to pass the type as a template parameter? Like this diff
--- a/plugin-statusnotifier/sniasync.h
+++ b/plugin-statusnotifier/sniasync.h
@@ -69,7 +69,7 @@ class SniAsync : public QObject
public:
SniAsync(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr);
- template <typename F>
+ template <typename T, typename F>
inline void propertyGetAsync(QString const &name, F finished)
{
static const std::vector<QString> ignored_errors = {
@@ -87,7 +87,7 @@ public:
QDBusPendingReply<QVariant> reply = *call;
if (reply.isError() && ignored_errors.cend() == std::find(ignored_errors.cbegin(), ignored_errors.cend(), reply.error().name()))
qDebug().noquote().nospace() << "Error on DBus request(" << mSni.service() << ',' << mSni.path() << ',' << name << "): " << reply.error();
- finished(qdbus_cast<typename std::function<typename call_signature<F>::type>::argument_type>(reply.value()));
+ finished(qdbus_cast<T>(reply.value()));
call->deleteLater();
}
);
with the help of https://stackoverflow.com/a/52556794
Also, std::function::argument_type was removed in C++20
It was deprecated before C++20. We should do something about it.
Fixed in #2305
Would it be possible to review the pull request please?