我在我的C ++项目中使用C++ socket.io library,我无法在项目头文件中包含所需的头文件。
但是当我在CPP文件中包含所需的头文件时,我成功地能够包含所需的头文件。
使用该库的步骤:
标题文件导入
#include <sio_message.h>
#include <sio_socket.h>
#include <sio_client.h>
在头文件中包含头文件时出错:
Severity Code Description Project File Line Suppression State
Error C2440 'initializing': cannot convert from 'nullptr' to 'const int &' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2838 'function<void __cdecl(sio::message::list const &)>': illegal qualified name in member declaration c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2838 'function<void __cdecl(sio::message::list const &)>': illegal qualified name in member declaration c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2440 'initializing': cannot convert from 'nullptr' to 'const int &' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2838 'list': illegal qualified name in member declaration c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2838 'list': illegal qualified name in member declaration c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2439 'sio::socket::ack': member could not be initialized c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2439 'sio::socket::ack': member could not be initialized c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2439 'sio::socket::msglist': member could not be initialized c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2439 'sio::socket::msglist': member could not be initialized c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2530 'sio::socket::name': references must be initialized c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 96
Error C2530 'sio::socket::name': references must be initialized c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 96
Error C2838 'string': illegal qualified name in member declaration c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2838 'string': illegal qualified name in member declaration c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2059 syntax error: ')' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2059 syntax error: ')' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2143 syntax error: missing ')' before 'const' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2143 syntax error: missing ')' before 'const' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2143 syntax error: missing ';' before 'const' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2143 syntax error: missing ';' before 'const' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
可能出现的问题:
答案 0 :(得分:1)
<强>解决方案:强>
我弄清楚发生了什么问题。 Socket.io C ++库和Qt共享命名空间关于单词&#34; emit&#34;。如果其他人遇到这个问题,我就是这样解决的:
希望这可以帮助其他人解决同样的问题。
注意:构建sioclient.lib文件时,我还遇到了另一个问题。您可能需要进行优化&#34;和&#34;调试&#34;其中一个项目文件夹中的文件夹。 CMAKE脚本错误地引用了项目中不存在的文件夹。那,或者从CMAKE脚本中删除这些行。