在 C++ 上包含 boost/asio.hpp 时出现编译器错误建造者2010
编辑:已解决!
我将 BOOST_ALL_NO_LIB 添加到我的条件定义中,并将 /libs/system/src/ 文件夹中的 errorcode.cpp 添加到我的项目中。
我最近安装了 C++ Builder,并一直在使用它来了解 C++。
我需要在我将要处理的项目中使用 boost-asio,但在尝试包含和编译它时遇到了一些问题。我已经设置了项目包含路径和所有应有的内容(我可以通过删除它来测试,编译器抱怨它找不到 asio.hpp,这不是问题)。
我尝试过 Boost 的 2 个版本:1_39 和 1_46,根据使用的版本,我会得到不同的错误。
我想,请忽略对初学者的警告。另外,如果您想要错误中的完整解析器上下文,请告诉我,我可以发布它们。
1_39:
[BCC32 警告] error_code.hpp(486): W8104 带构造函数的局部静态 对于多线程应用程序来说很危险
[BCC32 警告] error.hpp(349): W8104 带构造函数的局部静态 对于多线程应用程序来说很危险
[BCC32 错误] auto_link.hpp(262): E2075 不正确的编译指令 选项:-v
[BCC32 错误] static_log2.hpp(51): E2451 未定义的符号 'n'
[BCC32 错误] static_log2.hpp(55): E2451 未定义的符号“值”
[BCC32 错误] static_log2.hpp(55): E2230 内联数据成员 初始化需要一个积分 常量表达式
[BCC32 致命错误] static_log2.hpp(49): F1004 内部 0x55a4e8d 处的编译器错误 0x5500000
1_46:
[BCC32 警告] xutility(1808): W8017 “NOMINMAX”的重新定义不是 相同
[BCC32 警告] stdint.h(168): W8017 'WCHAR_MAX' 的重新定义不是 相同
[BCC32 警告] win_tss_ptr.ipp(41): W8012 比较有符号和无符号 价值观
[BCC32 警告] socket_select_interrupter.ipp(138): W8012 比较有符号和无符号 价值观
[BCC32错误]strand_service.hpp(31): E2247 'strand_service::do_complete(win_iocp_io_service) *,win_iocp_operation *,system::error_code,unsigned int)' 不可访问
[BCC32 警告] strand_service.ipp(95):W8058 不能 创建预编译头: 标头中的初始化数据
源代码并不重要,但无论如何(删除 asio 包含,显然我没有遇到任何麻烦):
//---------------------------------------------------------------------------
#include <boost/asio.hpp>
#include <iostream>
//---------------------------------------------------------------------------
int main ()
{
std::cout << "Test";
std::cin.ignore();
return 0;
}
//---------------------------------------------------------------------------
编辑:已解决!
我将 BOOST_ALL_NO_LIB 添加到我的条件定义中,并添加了errorcode.cpp 从 /libs/system/src/ 文件夹到我的项目。
EDIT: SOLVED!
I added BOOST_ALL_NO_LIB to my Conditional defines and added the errorcode.cpp from /libs/system/src/ folder to my Project.
I recently set up C++ Builder and been playing around with it to get my head around C++.
I need to use boost-asio for a project I will be working on, but I have come across a bit of a problem when just trying to include and compile it. I have set up the project include path and all as it should be (I can test by removing it and the compiler complains it can't find asio.hpp, this is not the issue).
I have tried with 2 versions of Boost, 1_39 and 1_46, and I get different errors depending on the version used.
Ignore the warnings for starters, I guess. Also, if you want the full parser context from the errors, please let me know and I can post them.
1_39:
[BCC32 Warning] error_code.hpp(486):
W8104 Local Static with constructor
dangerous for multi-threaded apps[BCC32 Warning] error.hpp(349): W8104
Local Static with constructor
dangerous for multi-threaded apps[BCC32 Error] auto_link.hpp(262):
E2075 Incorrect pragma directive
option: -v[BCC32 Error] static_log2.hpp(51):
E2451 Undefined symbol 'n'[BCC32 Error] static_log2.hpp(55):
E2451 Undefined symbol 'value'[BCC32 Error] static_log2.hpp(55):
E2230 In-line data member
initialization requires an integral
constant expression[BCC32 Fatal Error]
static_log2.hpp(49): F1004 Internal
compiler error at 0x55a4e8d with base
0x5500000
1_46:
[BCC32 Warning] xutility(1808): W8017
Redefinition of 'NOMINMAX' is not
identical[BCC32 Warning] stdint.h(168): W8017
Redefinition of 'WCHAR_MAX' is not
identical[BCC32 Warning] win_tss_ptr.ipp(41):
W8012 Comparing signed and unsigned
values[BCC32 Warning]
socket_select_interrupter.ipp(138):
W8012 Comparing signed and unsigned
values[BCC32 Error] strand_service.hpp(31):
E2247
'strand_service::do_complete(win_iocp_io_service
*,win_iocp_operation *,system::error_code,unsigned int)' is not accessible[BCC32 Warning]
strand_service.ipp(95): W8058 Cannot
create pre-compiled header:
initialized data in header
The source code doesn't really matter, but regardless (removing the asio include, I have no trouble, obviously):
//---------------------------------------------------------------------------
#include <boost/asio.hpp>
#include <iostream>
//---------------------------------------------------------------------------
int main ()
{
std::cout << "Test";
std::cin.ignore();
return 0;
}
//---------------------------------------------------------------------------
EDIT: SOLVED!
I added BOOST_ALL_NO_LIB to my Conditional defines and added the errorcode.cpp from /libs/system/src/ folder to my Project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据编辑解决:
我将 BOOST_ALL_NO_LIB 添加到我的条件定义中,并将 /libs/system/src/ 文件夹中的 errorcode.cpp 添加到我的项目中。
Solved as per the edit:
I added BOOST_ALL_NO_LIB to my Conditional defines and added the errorcode.cpp from /libs/system/src/ folder to my Project.