如何使用带有 clang/c2 的 boost asio
How to use boost asio with clang/c2
TL;DR:
- 有没有人能够将boost asio(boost版本是1.61)与clang/c2(集成到VS2015 Update 3中的clang++前端)一起使用?
- 如果是,您使用了哪些选项?
我有一个使用boost的asio库的程序。当在Win10上使用MSVC++(VS2015 Update 3)和在Ubuntu 14.04上使用g ++ 4.8编译时,它可以完美运行,但我也想使用新版本Visual Studio附带的clang前端(我相信从更新1开始)。
我的初始命令行选项(从项目属性页面复制)如下所示:
-fpic "stdafx.h" -std=c++1y -fstack-protector "Clang\" -fno-strict-aliasing -ffunction-sections -g2 -gdwarf-2 -O0 -x c++-header -D "_WINSOCK_DEPRECATED_NO_WARNINGS" -D "NOMINMAX" -frtti -fomit-frame-pointer -fdata-sections -fno-ms-compatibility -std=c11 -fexceptions -o "Clang\%(filename).obj" -fms-extensions -fno-short-enums
这给了我以下错误:
void __cdecl boost::detail::atomic_increment(struct __clang::_Atomic<int> *)': Unexpected atomic instruction -- use Windows interlock intrinsics
因此,显然使用 clang/c2 版本不支持的 clang/gcc 内部函数而不是使用 VC++ 编译时使用的 Windows 特定内部函数会感到疲倦。我尝试了不同的编译器选项,唯一似乎有任何效果的是取消定义__clang__
预处理器符号(将以下选项添加到命令行):
-U "__clang__"
这摆脱了原子错误,但现在我收到多页错误消息,这些错误消息似乎与某些增强 mpl 宏有关。以下是前几行:
1> In file included from main.cpp:1:
1> In file included from D:mylibsboostincludeboost/program_options.hpp:15:
1> In file included from D:mylibsboostincludeboost/program_options/options_description.hpp:13:
1> In file included from D:mylibsboostincludeboost/program_options/value_semantic.hpp:12:
1> In file included from D:mylibsboostincludeboost/any.hpp:20:
1> In file included from D:mylibsboostincludeboost/type_index.hpp:29:
1> In file included from D:mylibsboostincludeboost/type_index/stl_type_index.hpp:40:
1>D:mylibsboostincludeboost/mpl/if.hpp(131,23): error : too many arguments provided to function-like macro invocation
1> BOOST_MPL_AUX_NA_SPEC(3, if_)
1> ^
1> D:mylibsboostincludeboost/preprocessor/facilities/expand.hpp(26,10) : note: macro 'BOOST_PP_EXPAND_I' defined here
1> # define BOOST_PP_EXPAND_I(x) x
1> ^
有人对此有解决方案吗?
请注意,我的问题不是像这篇文章中那样构建 boost 库本身:b2 的命令参数,以便使用 Microsoft 的 Clang/C2 构建 Boost 库。是的,我知道 boost 没有官方支持 clang/c2,但我想知道是否有人知道一个可以产生正确 boost 配置宏集的黑客。
让 Boost 标头使用 Clang/C2 进行干净编译对于使 Clang/C2 有用至关重要,因此我们正在努力支持Clang-style
原子内部函数。它们将在 Clang/C2 的未来更新中提供。
我不知道有什么方法可以说服 Boost 在仍然使用 Clang 进行编译的同时使用 MSVC 版本的内联函数,除非您愿意破解 Boost 标头。
尝试在编译器选项中或在#include
任何 Boost 标头之前定义宏BOOST_SP_USE_STD_ATOMIC
。
- 理解boost::asio-async_read在无需读取内容时的行为
- boost::进程间消息队列引发错误
- 如何运行位于boost/libs/python/example/tutorial目录中的hello.cpp和Jamfil
- cmake如何在fedora工作站中找到boost静态库包
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- Boost Graph Library,修复节点大小
- 什么是"#include <boost/functional/hash.hpp> "?
- 基于boost的程序的静态链接——zlib问题
- C++:如何在CLion IDE中安装Boost
- C++Boost Asio Pool线程,带有lambda函数和传递引用变量
- 如何在boost beast http请求中设置http头
- Boost Spirit,获取迭代器内部语义动作
- boost::asio::steady_timer()与sleep()我应该使用哪一个
- boost::asio如何生成多个协同程序,然后加入它们
- 当我尝试使用 sstream 和分面将 Boost Time_duration转换为字符串时,我没有得到所需的格式
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 如何使用boost::具有嵌套结构和最小代码更改的序列化
- 使用Boost Interprocess创建托管共享内存需要很长时间
- 如何使用带有 clang/c2 的 boost asio
- b2 的命令参数,以便使用 Microsoft 的 Clang/C2 构建 Boost 库