Upgrading to Visual Studio 2005 - Part 1

I've been working to upgrade a complex project to Visual Studio 2005 and, not surprisingly, there are gotchas.  This is the first post in a series about the the things I've run into.  We'll start off with an easy one.

In C++, the pow function (raise number to a power) has lost one of its signatures, pow(int, int).  The fix is to cast the first argument to a double, float, or long double.  Thus, pow(2, 2) becomes pow((float) 2, 2) or pow(2.0f, 2).

The compiler error you'll receive when you try to use the missing signature is:

error C2668: 'pow' : ambiguous call to overloaded function
C:\Program Files\Microsoft Visual Studio 8\VC\include\math.h(575): could be 'long double pow(long double,int)'
C:\Program Files\Microsoft Visual Studio 8\VC\include\math.h(527): or 'float pow(float,int)'
C:\Program Files\Microsoft Visual Studio 8\VC\include\math.h(489): or 'double pow(double,int)'

MSDN documents this breaking change at http://msdn2.microsoft.com/en-us/library/dt5dakze.aspx .

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted @ Sunday, October 01, 2006 8:11 AM

Comments on this entry:

Gravatar # re: Upgrading to Visual Studio 2005 - Part 1
by Anil at 10/11/2006 5:53 AM

Thanks a lot buddy.was stuck on it for a while.
Anil
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: