Runtime_error was not declared in this area for g ++ 4.1.2

The same code works fine on gcc 4.5.2, but when I try to compile it on gcc 4.1.2 I get the error message 'runtime_error' was not declared in this scope .

I have

 #include <stdexcept> 

Is this a problem with gcc 4.1.2?

Code excerpt

 // Constructor if (resource cannot be acquired) throw std::runtime_error("Blah Blah"); 
+6
c ++ gcc linux
source share
3 answers

Visual Studio says that runtime_error should be defined in <stdexcept> , so I assume GCC 4.1.2 is just deprecated.

+5
source share

Do you have using namespace std; or using std::runtime_error; ? If not, then you need to fully qualify the name and use std::runtime_error , not just runtime_error .

+2
source share

gcc 4.1 is relatively old. 4.5 is more standard. You may have caused a compiler error

+1
source share

All Articles