-anthrax-

hi,

my program which was written in VC++ 6 worked perfectly fine untill i want to convert it in to VC++ 8 (2005). as i compile it in new compiler it gives me..

error C2660: 'ATL::CTime::GetGmtTm' : function does not take 0 arguments

: fatal error C1083: Cannot open include file: 'fstream.h': No such file or directory

1>.\SampleGroupRecordView.cpp(4470) : error C2668: 'pow' : ambiguous call to overloaded function

1> C:\Program Files\Microsoft Visual Studio 8\VC\include\math.h(575): could be 'long double pow(long double,int)'

1> C:\Program Files\Microsoft Visual Studio 8\VC\include\math.h(527): or 'float pow(float,int)'

1> C:\Program Files\Microsoft Visual Studio 8\VC\include\math.h(489): or 'double pow(double,int)'

1> while trying to match the argument list '(long, int)'

this three errors repeat in the program for hundreds of times.

i cant find "fstream.h" anywhere in my computer. do i need to install platform SDK

could you please give me an openian to lead me towords a solution.

thanks



Re: Visual C++ General error C2668: 'pow' : ambiguous call to overloaded function in VC++ 2005 only

Pintu Shukla

See don't use ".h" format for your header File like instead of <iostream.h> use <iostream> etc for pow function use <cmath> instead of <math.h>
Thanx





Re: Visual C++ General error C2668: 'pow' : ambiguous call to overloaded function in VC++ 2005 only

-anthrax-

nothing happend. still gives the same number of errors. any other suggetions please





Re: Visual C++ General error C2668: 'pow' : ambiguous call to overloaded function in VC++ 2005 only

Andreas Masur

-anthrax- wrote:

error C2660: 'ATL::CTime::GetGmtTm' : function does not take 0 arguments


Well...the function 'GetGmtTm()' actually expects one parameter passed to it which is a pointer to a 'tm' structure - see corresponding example in the MSDN.



-anthrax- wrote:

: fatal error C1083: Cannot open include file: 'fstream.h': No such file or directory



Visual Studio dropped the support of the old-style (and now deprecated) header files ending in '.h'. Using C++ you rather use the redesigned ones (without the .h extension) thus: #include <fstream>.


The only thing you need to remember is that everything inside the standard C++ headers is defined inside the namespace 'std'. Thus, you need to map the namespace to your application accordingly:



Code Snippet
// Using the full member name, including the namespace it belongs to:
std::cout << "Hello World";


// By taking advantage of using declarations:

using std::cout; // This declares 'cout' in the current scope as synonym for 'std::cout'


cout << "Hello World";



// By taking advantage of using directives:

using namespace std; // Specifies that the current scope can refer to names
in the 'std' namespace without using the full qualifiers.

cout << "Hello World";



// Using aliases

namespace x

{

namespace y

{

class z { ... };

}

}


X::Y::Z // Full qualifier for 'z'

namespace w = x::y; // Declares 'w' as an alias for namespace 'x::y'




-anthrax- wrote:

1>.\SampleGroupRecordView.cpp(4470) : error C2668: 'pow' : ambiguous call to overloaded function

1> C:\Program Files\Microsoft Visual Studio 8\VC\include\math.h(575): could be 'long double pow(long double,int)'

1> C:\Program Files\Microsoft Visual Studio 8\VC\include\math.h(527): or 'float pow(float,int)'

1> C:\Program Files\Microsoft Visual Studio 8\VC\include\math.h(489): or 'double pow(double,int)'

1> while trying to match the argument list '(long, int)'


Well...all this says is simply that the compiler is not able to resolve your function call. The function 'pow()' is overloaded for usage with different data types. Your call of the function would fit more than one definition of it...without seeing your corresponding code there is not much to say but it looks like you are calling it with an integer value...







Re: Visual C++ General error C2668: 'pow' : ambiguous call to overloaded function in VC++ 2005 only

-anthrax-

here where i get the problem with pow function

double CSampleGroupRecordView::CalculateErrors(long numberOfScansCompleted, double sumValue, double sqrValue)

{

double a, b, c, d;

if(numberOfScansCompleted == 1) return 0.0;

a = pow(sumValue, 2);

c = pow(numberOfScansCompleted, 2);

--->d = c * (numberOfScansCompleted - 1);

b = pow((((numberOfScansCompleted * sqrValue) - a) / d), 0.5);

return b;

}

does that means anything





Re: Visual C++ General error C2668: 'pow' : ambiguous call to overloaded function in VC++ 2005 only

alex.m

"pow" (any overload) takes a floating point type number (single, double or long double precision) as first argument, not an integer. This is where the error comes from, since the compiler can't guess the way you want your long integer to be converted.

Just try writing a cast expression, like this:

Code Block

c = pow((double)numberOfScansCompleted, 2);






Re: Visual C++ General error C2668: 'pow' : ambiguous call to overloaded function in VC++ 2005 only

-anthrax-

Simply beautiful, casting worked on pow function. Thanks mate.

still i have to figure out how can i include "fstream.h" to the project, which i cant find in my PC. do i need to install platform SDK





Re: Visual C++ General error C2668: 'pow' : ambiguous call to overloaded function in VC++ 2005 only

-anthrax-

thanks, your post was helpful in fixing 'GetGmtTm() error.

regards.





Re: Visual C++ General error C2668: 'pow' : ambiguous call to overloaded function in VC++ 2005 only

-anthrax-

thanks, include statement without .h extention worked.

regards





Re: Visual C++ General error C2668: 'pow' : ambiguous call to overloaded function in VC++ 2005 only

-anthrax-

thanks, it works

regards