clang++只在删除-std=c++11选项时使用boost::format编译c++11程序
clang++ only compiles C++11 program using boost::format when -std=c++11 option is dropped
请看下面的c++ 11代码片段:
#include <boost/format.hpp>
int main(int argc, char** argv)
{
auto s = boost::format("");
return 0;
}
当我使用-std=c++11
编译clang时,我得到以下错误:
$ clang++ -std=c++11 -o main main.cpp
In file included from main.cpp:1:
In file included from /usr/include/boost/format.hpp:19:
In file included from /usr/include/boost/detail/workaround.hpp:41:
In file included from /usr/include/boost/config.hpp:40:
In file included from /usr/include/boost/config/select_stdlib_config.hpp:18:
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/cstddef:51:11: error:
no member named 'max_align_t' in the global namespace
using ::max_align_t;
~~^
1 error generated.
没有-std=c++11
,一切都可以正常编译,但是clang打印了一个警告:
$ clang++ -o main main.cpp
main.cpp:5:3: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto s = boost::format("");
^
所以,看起来一个有效的解决方案是放弃c++ 11标志,因为当前版本的clang似乎处于c++ 11模式,不管怎样?缺点是你会得到很多警告。
除了完全切换到gcc之外,有没有更好的解决方案?修补boost::format或gcc-lib的源代码对我来说很好。
系统信息:
- 平台:Arch Linux x86_64
- Boost版本:1.55.0-6
- gcc-libs: 4.9.0-1
- clang++: 3.4 (tags/RELEASE_34/final)
该bug现已关闭。它应该在Arch中固定,clang 3.4-2。
在这个提交中,Evangelos Foutras从上游合并了以下补丁:http://reviews.llvm.org/rL201729
相关文章:
- C++ 11 Boost 1.65 recursive_directory_iterator给出分段错误
- Linux Mint 19 上的 CMake 3.11 无法找到静态的 Boost 库
- C++11 - 获取编译时的所有类变量,并在没有 Boost 的情况下为它们调用方法
- 用STD = C 11或其他标准编译Boost,例如Ash C 14
- C 11中的Boost ::变体和多态性
- 使用 C++11 选项编译 C++98 代码时由于 Boost 标头而导致的不明确重载
- g++-4.4(不在 C++11/14 中)通过 boost::shared_mutex 实现多读取器单编写器是否会影响
- 将 boost::thread 与 C++11 std::mutex 混合使用是否安全?
- C++11: boost::make_tuple 与 std::make_tuple 有何不同?
- 找出函子的返回类型 C++11Boost
- C++11 相关的编译错误与 g++ 4.6 和 boost::unordered_map
- 具有多个数组的类的构造函数启动器列表(C++11 是可以的,boost 和 std::vector 不是)
- C++ 11 中 boost::scoped_ptr 的替代方案
- 在 C++11 中是否有等效的 boost::interprocess::null_mutex(例如 std::null
- 用C 11 Boost实施的无法处于正常(Win/Linux)的事物列表
- 如何使用Visual Studio 2013 CTP 2013年11月11日建立Boost 1.55
- c++11 shared_ptr + Boost::Serialization
- 在QuantLib的日期类和C++11 / boost Chrno上
- 为什么c++ 11/Boost ' unordered_map '在擦除时不重新散列?
- c++ 11/Boost随机库,在循环的指定点开始生成