【发布时间】:2016-11-15 01:50:11
【问题描述】:
TL;DR:
- 是否有人能够将 boost asio(boost 版本为 1.61)与 clang/c2(集成到 VS2015 Update 3 中的 clang++ 前端)一起使用?
- 如果是,您使用了哪些选项?
我有一个使用 boost 的 asio 库的程序。在 Win10 上使用 MSVC++(VS2015 更新 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 -短枚举
这给了我以下错误:
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__"
这消除了原子错误,但现在我收到多页错误消息,这些消息似乎与某些 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> ^
有人对此有解决方案吗?
请注意,我的问题不是关于构建 boost 库本身,如本文所述:Command parameters for b2 in order to build Boost libraries with Microsoft's Clang/C2。是的,我知道 boost 没有对 clang/c2 的官方支持,但我想知道是否有人知道会产生正确的 boost 配置宏集的 hack。
【问题讨论】:
标签: c++ visual-studio boost build clang