runtime_error was not declared in this scope for g++ 4.1.2

前端 未结 3 2101
北荒
北荒 2021-02-20 11:17

The same code is working fine on gcc 4.5.2 but when trying to compile it on gcc 4.1.2, I get the error ‘runtime_error’ was not declared in this scope.

I do

相关标签:
3条回答
  • 2021-02-20 11:41

    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 rather than just runtime_error.

    0 讨论(0)
  • 2021-02-20 11:55

    Visual Studio says that runtime_error should be defined in <stdexcept>, so I'm guessing that GCC 4.1.2 is just out of date here.

    0 讨论(0)
  • 2021-02-20 12:01

    gcc 4.1 is relatively old. 4.5 is more standard compliant. Maybe you triggered a compiler's bug

    0 讨论(0)
提交回复
热议问题