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

Phi*_*ßen 7 c++ gcc boost clang c++11

请查看以下C++ 11片段:

#include <boost/format.hpp>

int main(int argc, char** argv)
{
  auto s = boost::format("");
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我用clang编译它时,-std=c++11我得到以下错误:

$ 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.
Run Code Online (Sandbox Code Playgroud)

没有-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("");
  ^
Run Code Online (Sandbox Code Playgroud)

因此,看起来一个有效的解决方法是删除C++ 11标志,因为当前版本的clang似乎是在C++ 11模式下,无论如何?缺点是你会得到很多警告.

除了完全切换到gcc之外,还有更好的解决方法吗?修补boost :: format或gcc-libs的源代码对我来说很好.


系统信息:

  • 平台:Arch Linux x86_64
  • 提升版:1.55.0-6
  • gcc-libs:4.9.0-1
  • clang ++:3.4(tags/RELEASE_34/final)

Phi*_*ßen 2

错误现已关闭。它应该用 clang 3.4-2 固定在 Arch 中。

通过此提交,Evangelos Fotras 合并了来自上游的以下补丁: http: //reviews.llvm.org/rL201729