[英]Using different Standard C++ library headers with Intel compiler
我試圖讓英特爾C ++編譯器使用不同於編譯器默認的標准庫C ++標頭。 遺憾的是,編譯器默認使用的標頭不會定義我需要的特定類型特征/功能。
$ icpc --version
icpc (ICC) 16.0.2 20160204
Copyright (C) 1985-2016 Intel Corporation. All rights reserved.
我想要使用的標題位於
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
但無論我嘗試什么,我都會得到
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"
(這里我認為編譯器使用它的默認標頭位置)或
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
(這里根本不使用任何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;
}
編輯:
只是為了確保這有正確的動機。 此系統上的默認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
^
找到了!
icpc -std=c++11 -o tes test.cc -cxxlib=/opt/crtdc/gcc/4.8.5-4/
英特爾編譯器期望可執行文件bin / gcc存在於該路徑中,並使用此可執行文件查詢C ++標頭的位置。
編譯器及其標准庫非常緊密。 我懷疑你會得到這種努力的任何地方。
使用不同的編譯器/ std lib或戳英特爾來修復它們的實現,然后升級。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.