home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progc
/
c_all592.arj
/
TI866.ASC
< prev
next >
Wrap
Text File
|
1992-04-16
|
1KB
|
67 lines
PRODUCT : C++ NUMBER : 866
VERSION : All
OS : WIN
DATE : April 16, 1992 PAGE : 1/1
TITLE : Using The Windows API Function MakeProcInstance
I keep getting a type mismatch error from the compiler when I
pass my function pointer to MakeProcInstance, and a type mismatch
error when I assign my function's return value to another
function pointer. Why?
Unless two functions take the same parameters, they are
considered to be of different types. Thus, if I declare a
DlgProc like so:
int FAR PASCAL _export DlgProc(HWND, WORD, WORD, DWORD);
I will get a type mismatch when I do:
MakeProcInstance(DlgProc, hInstance);
because MakeProcInstance expects a FARPROC for its first
parameter, which is declared to be a
typedef int (FAR PASCAL *FARPROC)();
To suppress this error, do this:
MakeProcInstance((FARPROC)DlgProc, hInstance);
That is typecast the function pointer you're passing to
MakeProcInstance to be the type it expects. Similarly, since
MakeProcInstance returns a FARPROC, you will get an error if you
assign its return value into other than a FARPROC. You would
need to either make the variable your assigning
MakeProcInstance's return value into a FARPROC, or typecast the
return value to the type of your variable.