现在的位置: 首页 > 综合 > 正文

socket编程里connect函数与qt冲突

2018年03月15日 ⁄ 综合 ⁄ 共 840字 ⁄ 字号 评论关闭

类中使用了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!

抱歉!评论已关闭.