开发者

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜