Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

std::error_code, std::system_error and std::generic_category

Garcia__Javier
Beginner
959 Views

Does the C++ standard library have these C++11 features?

My simple program:

#include <iostream>                     
                                        
std::error_code code;                   
                                        
int main() {                            
    std::cout << "Hello" << std::endl;
}                                       

fails to compile with the following error:

error: namespace "std" has no member "error_code"

This is the compile command I'm using:

icpc -std=c++11 -o test test.cpp

 

0 Kudos
2 Replies
Viet_H_Intel
Moderator
960 Views

What compiler version are you using? and you have GCC version < 5.1 

$ icpc t2.cpp -std=c++11 -V
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.4.243 Build 20190416
$ cat t2.cpp
#include <iostream>

std::error_code code;

int main() {
    std::cout << "Hello" << std::endl;
}
$
 

0 Kudos
Garcia__Javier
Beginner
960 Views

I wasn't aware that icpc needed GCC to run. I've loaded a newer GCC version and now the program compiles fine.

Thanks!

0 Kudos
Reply