Function pointers problem

N

Noah Roberts

Question: Why is the compiler complaining about conversion from typeA to
typeA function pointers?! AFAICT that is what it is doing...

Thanks,
NR

mingw message:

Dialup.cpp: In function `void DialupChooser(HWND__*, int, char*,
stack_t**)':
Dialup.cpp:92: invalid conversion from `BOOL (*)(HWND__*, unsigned int,
unsigned int, long int)' to `BOOL (*)(HWND__*, unsigned int,
unsigned int,
long int)'
Dialup.cpp: In function `void setup(HWND__*, int, char*, stack_t**, int,
BOOL
(*)(HWND__*, unsigned int, unsigned int, long int))':
Dialup.cpp:272: invalid conversion from `BOOL (*)(HWND__*, unsigned int,
unsigned int, long int)' to `BOOL (*)(HWND__*, unsigned int,
unsigned int,
long int)'


Declaration of function:


BOOL CALLBACK dchose_proc (HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam);

Declaration of setup():

static void setup(HWND hwndParent,
int string_size,
char *variables,
stack_t **stacktop,
int dialog_resource_id,
BOOL CALLBACK (*proc)(HWND,UINT,WPARAM,LPARAM));

Call to setup (line 92):

setup(hwndParent, string_size, variables, stacktop,
ID_CHOOSE_DIALOG,dchose_proc);

Line 272 (inside setup()):

dialog = CreateDialog(hinst,
MAKEINTRESOURCE(dialog_resource_id),
parent,
proc);
 
A

Alf P. Steinbach

Question: Why is the compiler complaining about conversion from typeA to
typeA function pointers?! AFAICT that is what it is doing...

...

Declaration of function:


BOOL CALLBACK dchose_proc (HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam);

Declaration of setup():

static void setup(HWND hwndParent,
int string_size,
char *variables,
stack_t **stacktop,
int dialog_resource_id,
BOOL CALLBACK (*proc)(HWND,UINT,WPARAM,LPARAM));

Call to setup (line 92):

setup(hwndParent, string_size, variables, stacktop,
ID_CHOOSE_DIALOG,dchose_proc);

Line 272 (inside setup()):

dialog = CreateDialog(hinst,
MAKEINTRESOURCE(dialog_resource_id),
parent,
proc);


Basically it's because you're using a non-standard extension of the
language, namely the specifier that the CALLBACK macro expands to.
What you have is a syntax error. You can "fix" that error by moving
CALLBACK into (*proc), just before the *, but it's Microsoft, not C++.

Instead of using such non-standard extensions all over the place, consider
using the types defined by the platform-specific header files you're using.

In this case, the DLGPROC type, which encapsulates the non-standard things
of the function pointer type definition.
 
N

Noah Roberts

Basically it's because you're using a non-standard extension of the
language, namely the specifier that the CALLBACK macro expands to.
What you have is a syntax error. You can "fix" that error by moving
CALLBACK into (*proc), just before the *, but it's Microsoft, not C++.

Instead of using such non-standard extensions all over the place, consider
using the types defined by the platform-specific header files you're using.

In this case, the DLGPROC type, which encapsulates the non-standard things
of the function pointer type definition.

Thanks, I didn't realize my problem was due to the non-standard stuff
but instead something with my C++ understanding. I will see if that
helps tomarro at work.

NR
 
N

Noah Roberts

Alf said:
Basically it's because you're using a non-standard extension of the
language, namely the specifier that the CALLBACK macro expands to.
What you have is a syntax error. You can "fix" that error by moving
CALLBACK into (*proc), just before the *, but it's Microsoft, not C++.

This seemed to work, thank you.
Instead of using such non-standard extensions all over the place, consider
using the types defined by the platform-specific header files you're using.

In this case, the DLGPROC type, which encapsulates the non-standard things
of the function pointer type definition.
I couldn't figure out how to do this one. It seems DLGPROC is actually
a double indirection, the other option was easier ;)

NR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top