By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

Function pointers problem

P: n/a
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);

Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Thu, 11 Dec 2003 14:40:49 -0800, Noah Roberts <nr******@dontemailme.com> wrote:
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.

Jul 22 '05 #2

P: n/a
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

Jul 22 '05 #3

P: n/a
Alf P. Steinbach wrote:
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

Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.