User forums > Help

"overflow_error", "fabs" etc not recognized as part of std when compiling

(1/1)

dacascos:
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
--- End quote ---
.

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;
}
--- End code ---

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'
--- End quote ---

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!

MortenMacFly:

--- Quote from: dacascos on November 07, 2009, 06:01:31 pm ---If code::blocks uses a newer standard or such,

--- End quote ---
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.

Navigation

[0] Message Index

Go to full version