我试图让英特尔C++编译器使用不同于编译器默认的标准库C++标头.遗憾的是,编译器默认使用的标头不会定义我需要的特定类型特征/功能.
$ icpc --version
icpc (ICC) 16.0.2 20160204
Copyright (C) 1985-2016 Intel Corporation. All rights reserved.
Run Code Online (Sandbox Code Playgroud)
我想要使用的标题位于
ls /opt/crtdc/gcc/4.8.5-4/include/c++/4.8.5/:
algorithm cfenv condition_variable cstring ext iostream numeric sstream tuple
array cfloat csetjmp ctgmath fenv.h istream ostream stack typeindex
atomic chrono csignal ctime forward_list iterator parallel stdexcept typeinfo
backward cinttypes cstdalign cwchar fstream limits profile streambuf type_traits
bits ciso646 cstdarg cwctype functional list queue string unordered_map
bitset climits cstdbool cxxabi.h future locale random system_error unordered_set
cassert clocale cstddef debug initializer_list map ratio tgmath.h utility
ccomplex cmath cstdint decimal iomanip memory regex thread valarray
cctype complex cstdio deque ios mutex scoped_allocator tr1 vector
cerrno complex.h cstdlib exception iosfwd new set tr2 x86_64-redhat-linux
Run Code Online (Sandbox Code Playgroud)
但无论我尝试什么,我都会得到
icpc -std=c++11 -o test test.cc -Qlocation,cxxinc,/opt/crtdc/gcc/4.8.5-4/include/c++/4.8.5/
error: namespace "std" has no member "declval"
Run Code Online (Sandbox Code Playgroud)
(这里我认为编译器使用它的默认标头位置)或
icpc -std=c++11 -o test test.cc -nostdinc++ -Qlocation,cxxinc,/opt/crtdc/gcc/4.8.5-4/include/c++/4.8.5/
test.cc(2): catastrophic error: cannot open source file "utility"
#include <utility> // std::declval
Run Code Online (Sandbox Code Playgroud)
(这里根本不使用任何C++标头,因为-nostdinc ++标志一起禁用它,我猜)
test.cc程序只是运用我需要的C++ 11标准库功能:
// declval example
#include <utility> // std::declval
#include <iostream> // std::cout
struct A { // abstract class
virtual int value() = 0;
};
class B : public A { // class with specific constructor
int val_;
public:
B(int i,int j):val_(i*j){
std::cout << "ctor\n";
}
int value() {return val_;}
};
int main() {
decltype(std::declval<A>().value()) a; // int a
decltype(std::declval<B>().value()) b; // int b
decltype(B(0,0).value()) c; // same as above (known constructor)
a = b = B(10,2).value();
std::cout << a << '\n';
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编辑:
只是为了确保这有正确的动机.此系统上的默认C++ 11标头不支持std :: declval.这就是为什么我尝试使用那些支持它的GCC.
$ icpc -std=c++11 -o test test.cc
opa.cc(19): error: namespace "std" has no member "declval"
decltype(std::declval<A>().value()) a; // int a
^
Run Code Online (Sandbox Code Playgroud)
找到了!
icpc -std=c++11 -o tes test.cc -cxxlib=/opt/crtdc/gcc/4.8.5-4/
Run Code Online (Sandbox Code Playgroud)
英特尔编译器希望该路径中存在可执行文件bin / gcc,并使用该可执行文件查询C ++头文件的位置。
Jes*_*uhl -1
编译器和它们的标准库有着非常紧密的联系。我怀疑你的努力会取得任何成果。
使用不同的编译器/std lib 或戳 Intel 来修复其实现,然后升级。
| 归档时间: |
|
| 查看次数: |
3145 次 |
| 最近记录: |