473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Function pointers problem

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
3 2175
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: Ben | last post by:
Hi, there. Recently I was working on a problem where we want to save generic closures in a data structure (a vector). The closure should work for any data type and any method with pre-defined...
3
by: Jan-Henrik Grobe | last post by:
Hallo, I am coming to this newsgroup with a very strange Problem. I have two c++ files A.cpp and B.cpp....In A.cpp I am creating an openGL window and in B.cpp I have stored the callback...
3
by: Markus Dehmann | last post by:
I have a class "Data" and I store Data pointers in an STL set. But I have millions of inserts and many more lookups, and my profiler found that they cost a lot of runtime. Therefore, I want to...
8
by: Mantorok Redgormor | last post by:
I have ran into a problem where I have a struct that has a member which contains a pointer to function and is initialized to a function in the initializer list. With my array of structs of this...
2
by: Jack | last post by:
I have a chunk of code that loads a few dozen function pointers into global variables. I'm concerned with unused memory consumption. What if the client only needs to use one or two functions? Then...
8
by: Klaas Vantournhout | last post by:
Hi all, I'm in need of a matrix of function pointers, and to be honest. No 'nice' solution has been found yet on that big big internet. It is possible to declare a matrix of function pointers...
12
by: Bill Pursell | last post by:
The following code generates a compiler warning when compiled with gcc -pedantic: typedef (*FUNC)(int); FUNC f; void * get_f(void) { return &f;
57
by: Robert Seacord | last post by:
i am trying to print the address of a function without getting a compiler warning (i am compiling with gcc with alot of flags). if i try this: printf("%p", f); i get: warning: format %p...
4
by: Christian Maier | last post by:
Hi After surfing a while I have still trouble with this array thing. I have the following function and recive a Segmentation fault, how must I code this right?? Thanks Christian Maier
20
by: MikeC | last post by:
Folks, I've been playing with C programs for 25 years (not professionally - self-taught), and although I've used function pointers before, I've never got my head around them enough to be able to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.