Pour obtenir une clé
d'essai remplissez le formulaire ci-dessous
Demandez des tariffs
Nouvelle licence
Renouvellement de licence
--Sélectionnez la devise--
USD
EUR
RUB
* En cliquant sur ce bouton, vous acceptez notre politique de confidentialité

Free PVS-Studio license for Microsoft MVP specialists
To get the licence for your open-source project, please fill out this form
** En cliquant sur ce bouton, vous acceptez notre politique de confidentialité.

I am interested to try it on the platforms:
** En cliquant sur ce bouton, vous acceptez notre politique de confidentialité.

Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
>
Strange errors occurring when compiling…

Strange errors occurring when compiling the 64-bit version of an application, error C2664

05 Avr 2013
Author:

Sometimes you may see questions about strange errors generated by the compiler when building 64-bit code.

A question may look in the following way:

//Class definition
class Type1 {...};
class Type2 {...};
class A
{
  public:
  ...
  void Func1(Type1* t1.....);
  void Func1(Type2& t2.....);
  ...
};
//Using Func1 function
A obj;
Type2 t2;
...
obj.Func1(t2,...);
...

This code successfully compiles in the 32-bit mode but the compiler generates the error C2664 (Type2 cannot be cast to Type1*) when trying to build the 64-bit version. Although the function taking Type2& as the argument is defined, the compiler, due to some reason, tries to use the function taking Type1* as the argument. What is the matter?

Most likely, the problem is in the other parameters which were replaced by dots in the example. Here is one more example of the code:

class Type1 {};
class Type2 {};
class A
{
public:
void Func1(Type1* t1, unsigned &);
void Func1(Type2& t2, size_t &);
};
void use() {
  A obj;
  Type2 t2;
  unsigned u;
  obj.Func1(t2, u);
}

It successfully compiles in the 32-bit mode. But in the 64-bit mode the both functions fail to work. The compiler considers the first function a better candidate because its second parameter meets the condition. Yet it announces that the first argument does not suit: error C2664: 'void A::Func1(Type1 *,unsigned int &)' : cannot convert parameter 1 from 'Type2' to 'Type1 *'. The solution is to carefully study the other arguments and modify the code as needed.

Comments (0)

Next comments
Unicorn with delicious cookie
Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus
Accepter