socket程式設計裡connect函式與qt衝突
阿新 • • 發佈:2019-01-08
類中使用了connect,一直報錯:
clientstart.cpp:68:63: error: no matching function for call to ‘ClientStart::connect(int&, sockaddr*, long unsigned int)’ if(connect(clientSocketFd, (SA *) &servaddr, sizeof(servaddr)) < 0) return 0; ^ clientstart.cpp:68:63: note: candidates are: In file included from /opt/Qt5.3.2/5.3/gcc_64/include/QtWidgets/qwidget.h:46:0, from /opt/Qt5.3.2/5.3/gcc_64/include/QtWidgets/qmainwindow.h:45, from /opt/Qt5.3.2/5.3/gcc_64/include/QtWidgets/QMainWindow:1, from clientstart.h:4, from clientstart.cpp:1: /opt/Qt5.3.2/5.3/gcc_64/include/QtCore/qobject.h:198:36: note: static QMetaObject::Connection QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType) static QMetaObject::Connection connect(const QObject *sender, const char *signal,
其實就是socket裡的connect與qt的發生衝突,把含有connect的程式碼改成:
if(::connect(clientSocketFd, (SA *) &servaddr, sizeof(servaddr)) < 0)
done!