cl ang 3.4 C 14支持

前端之家收集整理的这篇文章主要介绍了cl ang 3.4 C 14支持前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 travis.ci自动测试我的git仓库.

对于linux,他们使用:Ubuntu 12.04
与ang ang 3.4

根据clang page,所有C 14语言特性都由Clang 3.4支持(只要使用-std = c 1y标志).

到现在为止还挺好:
我还需要使用std :: index_sequence< t0,...,tn>这是库功能N3658不是一个语言功能.但是我找不到有关更新C标准库的具体文档,以确保该功能得到支持(开箱即用).

TestCode:

#include <utility>
int main() {
    std::index_sequence<1,2,3,4>    seq;
}

TestBuild:

> clang++ -std=c++1y pl.cpp
pl.cpp:3:10: error: no member named 'index_sequence' in namespace 'std'
    std::index_sequence<1,4>    seq;
    ~~~~~^
pl.cpp:3:37: error: use of undeclared identifier 'seq'
    std::index_sequence<1,4>    seq;
                                    ^
2 errors generated.

更新:

根据下面的建议,我试图使用libc.
很确定我做错了,但我从来没有尝试使用替代的标准库,所以我不知道这里出了什么问题.将在今晚挖但是如果您有建议,请发表评论.

> sudo apt-get install -qq libc++1 libc6 libc++-dev

> clang++ -stdlib=libc++ pl.cpp
pl.cpp:1:10: fatal error: 'utility' file not found
#include <utility>
         ^
1 error generated.

解决方法

那么答案似乎是安装g -4.9
这将更新已安装的标准库,以便clang能够编译代码.
sudo apt-get install python-software-properties
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.9

## Because I also use llvm-cov from my makefile
## I have to make sure it is in the path.
a=$(sudo find / -name llvm-cov | head -1)
sudo ln -s ${a} /usr/bin/llvm-cov

所以这是我添加到travis.yml文件

before_install:
    - if [ "$TRAVIS_OS_NAME" == "linux" -a "$CXX" == "clang++" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test;fi
    - if [ "$TRAVIS_OS_NAME" == "linux" -a "$CXX" == "clang++" ]; then sudo apt-get update;fi
    - if [ "$TRAVIS_OS_NAME" == "linux" -a "$CXX" == "clang++" ]; then sudo apt-get install g++-4.9;fi
    - if [ "$TRAVIS_OS_NAME" == "linux" -a "$CXX" == "clang++" ]; then a=$(sudo find / -name llvm-cov | head -1);sudo ln -s ${a} /usr/bin/llvm-cov;fi

在我巩固我的g和clang预构建代码之后:

before_install:
    - if [ "$TRAVIS_OS_NAME" == "linux"];                         then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y;fi
    - if [ "$TRAVIS_OS_NAME" == "linux"];                         then sudo apt-get update;fi
    - if [ "$TRAVIS_OS_NAME" == "linux"];                         then sudo apt-get install -qq g++-4.9;fi
    - if [ "$TRAVIS_OS_NAME" == "linux" -a "$CXX" == "g++" ];     then sudo update-alternatives --install /usr/bin/gcc  gcc  /usr/bin/gcc-4.9  90;fi
    - if [ "$TRAVIS_OS_NAME" == "linux" -a "$CXX" == "g++" ];     then sudo update-alternatives --install /usr/bin/g++  g++  /usr/bin/g++-4.9  90;fi
    - if [ "$TRAVIS_OS_NAME" == "linux" -a "$CXX" == "g++" ];     then sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-4.9 90;fi
    - if [ "$TRAVIS_OS_NAME" == "linux" -a "$CXX" == "clang++" ]; then a=$(sudo find / -name llvm-cov | head -1);sudo ln -s ${a} /usr/bin/llvm-cov;fi
原文链接:https://www.f2er.com/c/114123.html

猜你在找的C&C++相关文章