error C2440: 'initializing' : cannot convert from 'LPVOID' to 'UINT
Im getting the following error while trying to convert code from C to C++:
error C2440: 'initializing' : cannot convert from 'LPVOID' to 'UINT (__cdecl *)(LPVOID,UINT,LPWSTR,UINT)'
Here's the piece of code causing problems:
UINT (*GetString)( LPVOID rsrc, UINT res, LPWSTR buf, UINT len )
开发者_高级运维 = (LPVOID)0x4347e0;
How do I fix it?
You're trying to convince the compiler to treat 0x4347e0 (which is of type 'int') to be a pointer to a function taking 4 parameters. Casting the int to LPVOID isn't going to satisfy the compiler - you need to cast it to the right thing:
typedef UINT (*GetStringFnPtr)(LPVOID rsrc, UINT res, LPWSTR buf, UINT len );
GetStringFnPtr GetString = (GetStringFnPtr)0x4347e0;
精彩评论