'sqrt' : undeclared identifier
-
Why is that Visual C++'s GUI knows about
sqrt
yet the compiler doesn't? :confused: As I edit my source I typed in sqrt and as I start to type in the paramters the GUI presents me with 3 different prototypes ofsqrt
... I think cool Visual C++ knows aboutsqrt
... so I typedsqrt( myDouble );
as per the GUI. Yet I get a compiler error? X| -
Why is that Visual C++'s GUI knows about
sqrt
yet the compiler doesn't? :confused: As I edit my source I typed in sqrt and as I start to type in the paramters the GUI presents me with 3 different prototypes ofsqrt
... I think cool Visual C++ knows aboutsqrt
... so I typedsqrt( myDouble );
as per the GUI. Yet I get a compiler error? X|Because the IDE searchs all the headers in the include paths, but the compiler requires that you include them. It's probably math.h, or cmath ( which, if it works, is preferred ). Also cmath may require you use std::sqrt. All of this is a guess, but I am pretty sure that math.h at least will be the right one, and it's certainly a missing #include. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002 -
Because the IDE searchs all the headers in the include paths, but the compiler requires that you include them. It's probably math.h, or cmath ( which, if it works, is preferred ). Also cmath may require you use std::sqrt. All of this is a guess, but I am pretty sure that math.h at least will be the right one, and it's certainly a missing #include. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002My code looks kinda like this ...
#include "math.h"
#include "stdafx.h"
.
.
.
double BlahBlah::Blah_Abs ( double real, double img ) {
double rc = real * real + img * img;
return sqrt( rc );
}
.
.
.Yet the compiler does not complain about not be able to find math.h in the include path so I must assume that VC++ knows about math.h and since the compiler errors on
sqrt ( rc );
I guess thatsqrt( double )
is not declared in math.h :confused: -
My code looks kinda like this ...
#include "math.h"
#include "stdafx.h"
.
.
.
double BlahBlah::Blah_Abs ( double real, double img ) {
double rc = real * real + img * img;
return sqrt( rc );
}
.
.
.Yet the compiler does not complain about not be able to find math.h in the include path so I must assume that VC++ knows about math.h and since the compiler errors on
sqrt ( rc );
I guess thatsqrt( double )
is not declared in math.h :confused: -
My code looks kinda like this ...
#include "math.h"
#include "stdafx.h"
.
.
.
double BlahBlah::Blah_Abs ( double real, double img ) {
double rc = real * real + img * img;
return sqrt( rc );
}
.
.
.Yet the compiler does not complain about not be able to find math.h in the include path so I must assume that VC++ knows about math.h and since the compiler errors on
sqrt ( rc );
I guess thatsqrt( double )
is not declared in math.h :confused:sqrt
requires#include <math.h>
/ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com -
My code looks kinda like this ...
#include "math.h"
#include "stdafx.h"
.
.
.
double BlahBlah::Blah_Abs ( double real, double img ) {
double rc = real * real + img * img;
return sqrt( rc );
}
.
.
.Yet the compiler does not complain about not be able to find math.h in the include path so I must assume that VC++ knows about math.h and since the compiler errors on
sqrt ( rc );
I guess thatsqrt( double )
is not declared in math.h :confused:Just to reiterate and add my voice to the cacophany, the intellisense parses all include paths, but the compiler will only compile if you actually include the bits you need in your code. I suggest that it's a wise course of action when people answer your question to try the suggested solution before arguing about it. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002 -
Just to reiterate and add my voice to the cacophany, the intellisense parses all include paths, but the compiler will only compile if you actually include the bits you need in your code. I suggest that it's a wise course of action when people answer your question to try the suggested solution before arguing about it. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002I am including math.h but codeproject thinks le math.h ge is somekind of HTML tag! X| And WTF is this ... I suggest that it's a wise course of action when people answer your question to try the suggested solution before arguing about it. ... about? I am not arguing about anything :omg:
-
I am including math.h but codeproject thinks le math.h ge is somekind of HTML tag! X| And WTF is this ... I suggest that it's a wise course of action when people answer your question to try the suggested solution before arguing about it. ... about? I am not arguing about anything :omg:
My apologies - you didn't check the 'display message as is' option, nor did you use the buttons above the emoticons which would replace a < with a < and so on, making it show OK. As a result I presumed you were saying what you said in the first place, as did all the other people who replied. I see you have edited the code now :0)
#include "math.h"
#include "stdafx.h"Anything before stdafx.h is ignored. Move it down and it will work. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002 -
My apologies - you didn't check the 'display message as is' option, nor did you use the buttons above the emoticons which would replace a < with a < and so on, making it show OK. As a result I presumed you were saying what you said in the first place, as did all the other people who replied. I see you have edited the code now :0)
#include "math.h"
#include "stdafx.h"Anything before stdafx.h is ignored. Move it down and it will work. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002Christian Graus wrote: Anything before stdafx.h is ignored. Move it down and it will work. As noted on page 216 of Programming Windows with MFC. ;P I knew I had read that before and I had to look it up.
Nick Parker
You see the Standards change. - Fellow co-worker
-
My apologies - you didn't check the 'display message as is' option, nor did you use the buttons above the emoticons which would replace a < with a < and so on, making it show OK. As a result I presumed you were saying what you said in the first place, as did all the other people who replied. I see you have edited the code now :0)
#include "math.h"
#include "stdafx.h"Anything before stdafx.h is ignored. Move it down and it will work. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002