Can I typedef pointer to extern (C) function?

Mike Parker aldacron71 at yahoo.com
Sat Jan 27 01:12:49 PST 2007


Rick Mann wrote:
> 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.

Switch up the 'alias' and extern(C) statements:

extern(C) alias uint function() EventHandlerProcPtr;


>>
>> extern (C)
>> uint
>> func1()
>> {
>> 	return 0;
>> }
>>
>> uint
>> func2()
>> {
>> 	return 0;
>> }
>>
>> void
>> main()
>> {
>> 	EventHandlerProcPtr p = &func1;
>> 	EventHandlerProcPtr q = &func2;
>> }
>>
>>

Also, as written, func2 is not extern(C), only func1 is. That's likely 
why you only saw the error for func1.



More information about the Digitalmars-d mailing list