Argument of type "unsigned long *" is incompatible with parameter of type "HCRYPTHASH *"

804 views Asked by At

I'm using Visual Studios 2012 on Windows 8.1, on a 64 bit machine. I'm having trouble compiling the following code for c++, getting the above error:

#include <windows.h>
#include <wincrypt.h>
void MD5Init(MD5Context *ctx)
{
    CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &ctx->hHash);
}

However, this seems to be the way this is called (here is one which has the same call and gives me the same error). VS suggests a couple of possible fixes, which I'll try, but does anyone know why this behaviour is happening and how to avoid it?

The suggested fixes are:

error C2664: 'CryptCreateHash' : cannot convert parameter 5 from 'unsigned long *' to 'HCRYPTHASH *' Types pointed to are unrelated;

conversion requires reinterpret_cast, C-style cast or function-style cast

Thanks,

Aodhán

Edit: It doesn't happen for 32 bit compilation, so I guess that's what the examples I've read were done in. I'll update whether the suggested fixes worked for 64 bit compilation.

0

There are 0 answers