I am trying to complie a simple program with math functions sqrt() and fabs
using gcc 3.4.3  (Red Hat 3.4.3-9.EL4). I am not able to compile without
including #include <math.h> but same code works with earlier versions of gcc
3.3.3 (Suse ) and gcc 3.3.3 (Red Hat 3.2.3-42).

Code:
#include<iostream.h>
int main()
{
        double k =1.4;
        cout<<sqrt(k)<<endl;
        cout<<fabs(k)<<endl;
        return 1;
}

Compilation command: g++ -o main main.cpp -w

Error:

main.cpp: In function `int main()':
main.cpp:5: error: `sqrt' undeclared (first use this function)
main.cpp:5: error: (Each undeclared identifier is reported only once for each
function it appears in.)
main.cpp:6: error: `fabs' undeclared (first use this function)


I have a large piece of software that have code in this manner i.e, using math
functions without including #include<math.h> and would like to migrate to gcc 
3.4.3.

Please do advice.

Thanks,

-- 
           Summary: Problems while compiling with some math functions.
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sreevatsan at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21287

Reply via email to