Warning on 'visibility' attribute of "QDebug& operator<<(QDebug &dbg, const KAsync::Error &error)"
Closed, ResolvedPublic

Description

I don't know if this is the right place to report this problem, but I couldn't find kasync on bugs.kde.org.

I'm building packages for kube and all its dependencies for the Archlinux AUR and I have a problem with kasync and sink. I get this warning while compiling kasync:

In file included from /home/marco/pkg/kasync-git/src/kasync/src/future.cpp:18:0:
/home/marco/pkg/kasync-git/src/kasync/src/future.h:496:73: warning: ‘visibility’ attribute ignored on non-class types [-Wattributes]
 QDebug& KASYNC_EXPORT operator<<(QDebug &dbg, const KAsync::Error &error);
                                                                         ^

And then I get this error while compiling sink:

../common/libsink.so.0.1: riferimento non definito a "operator<<(QDebug&, KAsync::Error const&)"
collect2: error: ld returned 1 exit status
make[2]: *** [synchronizer/CMakeFiles/sink_synchronizer.dir/build.make:125: synchronizer/sink_synchronizer] Error 1
make[1]: *** [CMakeFiles/Makefile2:990: synchronizer/CMakeFiles/sink_synchronizer.dir/all] Error 2
make: *** [Makefile:139: all] Error 2

I found this message on the kdevelop-devel mailing list about the same topic, so I tried replacing line 496 of file future.h with this one:

KASYNC_EXPORT QDebug& operator<<(QDebug &dbg, const KAsync::Error &error);

In this way I compiled kasync without warnings and sink without errors.

I'm using these commands to build both kasync and sink, maybe I'm missing something:

cmake -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release \
    -DLIB_INSTALL_DIR=lib \
    -DKDE_INSTALL_USE_QT_SYS_PATHS=ON
make

Sorry, I found this just now. You are using clang. Using options from that json file it builds fine.

marcoscarpetta closed this task as Invalid.Feb 4 2017, 8:46 AM
dvratil added a subscriber: dvratil.Feb 5 2017, 9:24 PM

Your initial patch was correct, the KASYNC_EXPORT macro should be at the beginning of the line, Clang is maybe more forgiving regarding the placement of attributes than GCC.... I fixed it in master.

Ok, I thought that clang had a different syntax for attributes. I found the same error in Sink, this is a patch for it.

marcoscarpetta reopened this task as Open.Feb 6 2017, 8:10 AM
marcoscarpetta added a project: Sink.
cmollekopf closed this task as Resolved.Feb 10 2017, 10:04 AM
cmollekopf claimed this task.
cmollekopf added a subscriber: cmollekopf.

Thanks for the patch! (I applied it locally and will push it in a bit).