Can I typedef pointer to extern (C) function?

Rick Mann rmann-d-lang at latencyzero.com
Fri Jan 26 23:38:21 PST 2007


Rick Mann Wrote:

> Rick Mann Wrote:
> 
> > I'm having trouble posting. If this succeeds, I'll post the rest in a follow-on.
> 
> So, I have the following example (gdc on Mac OS X, DMD 1.00-based):
>

Sorry,  forgot the rest of the question. It seems to dislike the "extern (C)" in my target function declaration, but I get bus errors if I omit it (as one might expect).

Any suggestions would be most welcome.

> 
> 
> alias extern (C) uint function()		EventHandlerProcPtr;
> 
> extern (C)
> uint
> func1()
> {
> 	return 0;
> }
> 
> uint
> func2()
> {
> 	return 0;
> }
> 
> void
> main()
> {
> 	EventHandlerProcPtr p = &func1;
> 	EventHandlerProcPtr q = &func2;
> }
> 
> 
> /*
> 	Compiling with gdc generates the following errors:
> 	
> 	$ gdc callbacktest.d 
> 	callbacktest.d:23: Error: cannot implicitly convert expression (& func1) of type uint(C *)() to uint(*)()
> 	$ 
> 
> */




More information about the Digitalmars-d mailing list