如何使用clang/c2的boost asio

Mik*_*eMB 2 c++ boost build clang visual-studio

TL; DR:

  • 有没有人能够使用boost asio(升级版本是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-枚举

这给了我以下错误:

void __cdecl boost::detail::atomic_increment(struct __clang::_Atomic<int> *)': Unexpected atomic instruction -- use Windows interlock intrinsics
Run Code Online (Sandbox Code Playgroud)

显然,使用clang/c2版本不支持的clang/gcc内在函数而不是使用在使用VC++编译时使用的特定于Windows的内在函数会增加疲劳.我玩了不同的编译器选项,似乎唯一有效的是取消定义__clang__预处理器符号(在命令行中添加以下选项):

-U "__clang__"
Run Code Online (Sandbox Code Playgroud)

这摆脱了原子错误,但现在我得到多页错误消息似乎与一些boost mpl宏有关.以下是前几行:

1>  In file included from main.cpp:1:
1>  In file included from D:\mylibs\boost\include\boost/program_options.hpp:15:
1>  In file included from D:\mylibs\boost\include\boost/program_options/options_description.hpp:13:
1>  In file included from D:\mylibs\boost\include\boost/program_options/value_semantic.hpp:12:
1>  In file included from D:\mylibs\boost\include\boost/any.hpp:20:
1>  In file included from D:\mylibs\boost\include\boost/type_index.hpp:29:
1>  In file included from D:\mylibs\boost\include\boost/type_index/stl_type_index.hpp:40:
1>D:\mylibs\boost\include\boost/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:\mylibs\boost\include\boost/preprocessor/facilities/expand.hpp(26,10) :  note: macro 'BOOST_PP_EXPAND_I' defined here
1>  # define BOOST_PP_EXPAND_I(x) x
1>           ^
Run Code Online (Sandbox Code Playgroud)

有人有解决方案吗?

请注意,我的问题不是像本文中那样构建boost库本身:b2的命令参数,以便使用Microsoft的Clang/C2构建Boost库.是的,我知道来自boost的clang/c2没有官方支持,但我想知道是否有人知道会产生正​​确的boost配置宏的hack.

小智 5

使用Clang/C2获得Boost标头以便干净地编译对于使Clang/C2变得有用至关重要,因此我们正致力于支持原子内在函数.它们将在Clang/C2的未来更新中提供.Clang-style

我不知道有什么方法可以说服Boost在使用Clang进行编译的同时使用MSVC版本的内在函数,除非你愿意破解Boost头文件.