In xp 32bit this line compiles with not problem however in vista 64bit this line:
m_FuncAddr = ::GetProcAddress (somthing);
gives the following error
error C2440: ‘=’ : cannot convert from ‘FARPROC’ to ‘int (__cdecl *)(void)’
GetProcAddress is defined as
WINBASEAPI FARPROC WINAPI GetProcAddress (somthing)
And m_FuncAddr as
int (WINAPI *m_FuncAddr)();
From what I understand both are stdcall’s.
To avoid the error I had to put
m_FuncAddr = (int (__cdecl *)(void))::GetProcAddress(somthing);
My Question:
If both m_FuncAddr and GetProcAddress have the stdcall calling convention why do I have to ‘recall’ it with cdecl ?
Is it possible that the VS project setting ‘default calling convention (which is set to cdecl) over-rides the assignemet statment above ?
Thanks in advance!
[Edit]
To clerfiy the question:
On one side of the equation (say side 1) i have
int __stdcall * m_FuncAddr
On other side (side 2)
INT_PTR far __stdcall GetProcAddress
So how is it that i have to cast side 2 with cdecl if both are stdcalls ? Or am I not getting something ?
The return type should be INT_PTR (a 64-bit value in 64-bit builds). You shouldn’t cast around this error — the compiler is trying to tell you that something is wrong.
From WinDef.h:
So the declaration of m_FuncAddr should be: