int C function

Ellery Newcomer ellery-newcomer at utulsa.edu
Sat Oct 1 11:21:16 PDT 2011


On 10/01/2011 08:33 AM, Andrej Mitrovic wrote:
> On 10/1/11, Ellery Newcomer <ellery-newcomer at utulsa.edu> wrote:
>> On 09/30/2011 08:20 PM, Andrej Mitrovic wrote:
>>> I think this is a side-effect of the new function pointer fixes, where
>>> you now can't implicitly convert an extern(C) function to an extern(D)
>>> function by accident (and that's a good thing). But the problem is,
>>> you can't define a function with a different linkage type inline as a
>>> type parameter. You have to use an alias instead:
>>
>> wait, are there explicit ways to convert extern(C) funcs <-> extern(D)
>> funcs?
>>
> 
> You can convert anything with an explicit cast, but it doesn't make
> much sense to cast between calling conventions types. The compiler
> used to allow taking an address of an extern(C) function and assigning
> it to an extern(D) function pointer. But this would just result in
> segfaults and memory corruption due to how parameters are passed.

What what? C and D functions have different calling conventions?

oh, is this for variadic argument?

> 
> Nice code-golf, btw.

I think it looks horrible :)


More information about the Digitalmars-d-learn mailing list