Я использую C++ socket.io library в моем проекте на C++, и я не могу включить требуемые файлы заголовков в заголовочный файл моих проектов.Почему я не могу импортировать файлы заголовков в библиотеку в один из моих файлов заголовков?
Но когда я включаю требуемые файлы заголовков в свой файл CPP, я успешно могу включить необходимые файлы заголовков.
Меры, принятые для использования библиотеки:
- скомпилировать C++ websocketpp, OpenSSL, библиотека подталкивание и подготовить библиотеку JSON.
- Ссылка на * .lib-файлы в моем проекте VS2015.
- Включите расположение файлов заголовков в дополнительной папке зависимостей C++.
- Включите расположение файлов * .lib в папке зависимостей Linker include.
- Включите три файла заголовка в файл 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
Возможные проблемы:
- Общее пространство имен? Возможно, я распространяю неправильное пространство имен?
- Циркулярные зависимости? Возможно, я вызываю циклическую зависимость, включая заголовочные файлы в моем классе, и один из других файлов заголовков включает этот же файл.