Author Topic: "overflow_error", "fabs" etc not recognized as part of std when compiling  (Read 8223 times)

dacascos

  • Guest
I am fairly new to c++ but taking a course in it at uni which is adapted to unix systems but using code::blocks to practise from home. The recommended compiler command in the unix systems is:
Quote
g++ -g -std=c++98 -pedantic -Wall -Wextra lab1.cc
.

Trying to compile a basic function example I get errors when using c::b. Code below:

Code
double divide(double a, double b)
{
    if (std::fabs(b) < 1.0 &&
        std::fabs(a) > std::numeric_limits<double>::max()*std::fabs(b))
        throw std::overflow_error("arithmetic_error");

    double result = a / b;
    if (a != 0 && result == 0.0)
        throw std::underflow_error("arithmetic_error");
    return result;
}

Compiling results in the following errors:

Quote
error: 'fabs' is not a member of 'std'
error: 'overflow_error' is not a member of 'std'
error: 'underflow_error' is not a member of 'std'

If code::blocks uses a newer standard or such, can I adjust compiler to simulate the recommended course settings? I want to be able to practise in the standard I am supposed to use at the exam. Please help me!

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: "overflow_error", "fabs" etc not recognized as part of std when compiling
« Reply #1 on: November 07, 2009, 06:07:21 pm »
If code::blocks uses a newer standard or such,
Code::Blocks is an IDE, not a compiler. So you are talking about compiler errors, which we don't support. This question is therefore not related to Code::blocks and thus violates our forum rules. Try a GCC / C++ forum, please.

Topic locked.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ