c++ - 当 -std=c++11 选项被删除时,clang++ 仅使用 boost::format 编译 C++11 程序

标签 c++ gcc c++11 boost clang

请看下面的 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-libs 的源代码对我来说很好。


系统信息:

  • 平台:Arch Linux x86_64
  • boost 版本:1.55.0-6
  • gcc-libs: 4.9.0-1
  • clang++:3.4(标签/RELEASE_34/final)

最佳答案

bug现在关闭了。它应该在 Arch 中用 clang 3.4-2 修复。

this commit , Evangelos Foutras 从上游合并了以下补丁: http://reviews.llvm.org/rL201729

关于c++ - 当 -std=c++11 选项被删除时,clang++ 仅使用 boost::format 编译 C++11 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23462950/

相关文章:

c++ - 什么时候隐式 move 构造函数不够好?

c++ - C++中高效的多维数据存储

c++ - Eclipse 中的 MakeFile 是什么?

c++ - 在编译时将不以 '\0' 结尾的 const char 数组与 C 风格字符串分开

macos - 如何在Mac OS X上进行ARM交叉编译(错误: invalid listing option `r' - cross compiling error)

c++ - 有没有办法在 GCC 中禁用内联汇编程序?

c++ - 随机 double 总是无限的

c++ - Type Alias 一个自定义类的对象

c++ - 返回对特定大小数组的引用,而不在返回类型中明确说明大小

c - 推荐的 C 的 GCC 警告选项