Using various headers of the Standard C ++ library with Intel compiler

I am trying to use the Intel C ++ compiler for different standard C ++ libraries than for standard compilers. The headers that the compiler will use by default, unfortunately, do not define the specific type / function of the type that I need.

$ icpc --version icpc (ICC) 16.0.2 20160204 Copyright (C) 1985-2016 Intel Corporation. All rights reserved. 

The headings I would like to use are located in

 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 

But no matter what I try, I either get

 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" 

(here I think the compiler uses it by default for the header) or

 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 

(here it doesn't use C ++ headers at all, because the -nostdinC ++ flag disables it all together, I think)

The test.cc program simply uses the standard C ++ 11 library, which I will need:

 // 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; } 

EDIT:

Just to make sure it is properly motivated. The default C ++ 11 headers on this system do not support std :: declval. Therefore, I am trying to use GCC that support it.

 $ 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 ^ 
+6
source share
2 answers

Found it!

 icpc -std=c++11 -o tes test.cc -cxxlib=/opt/crtdc/gcc/4.8.5-4/ 

The Intel compiler expects the bin / gcc executable to be present in this path and will request the location of the C ++ headers using this executable.

+4
source

Compilers and their standard libraries are pretty closely related. I doubt that you will end up with it anyway.

Use another compiler / std lib or call Intel to fix their implementation, and then upgrade.

-one
source

All Articles