Declaring a D pointer to a C function
Steven Schveighoffer
schveiguy at yahoo.com
Wed Jul 13 10:08:38 PDT 2011
On Wed, 13 Jul 2011 11:32:50 -0400, Daniel Murphy
<yebblies at nospamgmail.com> wrote:
> "Andrej Mitrovic" <andrej.mitrovich at gmail.com> wrote in message
> news:mailman.1607.1310570915.14074.digitalmars-d-learn at puremagic.com...
>> Thanks! I've literally lost an entire day once when I was just
>> starting using D and C together and had a calling convention mismatch.
>> :x
>
> It's worse than just calling conventions - try changing the parameter
> types!
> (or basically anything except the return type)
Yeah, examining the assembly, a major difference is that D passes one
parameter in a register, whereas C pushes it on the stack. This means you
are going to have off-by-one corruption any time you access a parameter.
-Steve
More information about the Digitalmars-d-learn
mailing list