Need extern (C) interface even though using Derelict GLFW

Rikki Cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 4 16:14:44 PST 2015


On 5/01/2015 9:30 a.m., WhatMeWorry wrote:
> On Sunday, 4 January 2015 at 09:02:48 UTC, Mike Parker wrote:
>> On 1/4/2015 1:34 PM, WhatMeWorry wrote:
>>
>>> Maybe GLFW callback functions can't handled through Derelict GLFW?
>>>
>>>
>> And just to be clear, because the pointers to the callback functions
>> are being passed to a C API, they *have* to be extern( C ) -- i.e.
>> they have to have the same calling convention that the C library
>> expects. If the library functions used the stdcall calling convention
>> rather than cdecl, then the callbacks would have to be extern( Windows
>> ). So even a wrapper that allows you to pass D delegates or function
>> pointers would still have to internally give GLFW a pointer to a
>> function with the proper calling convention.
>
> Thanks for the replies. I felt like I was creating a kludge.
>
>
> I have to confess that the above paragraph is pretty much
> incomprehensible to me.  Except for "function pointers" the rest of the
> terms I have seen before, but can't really make out into a meaningful
> whole.
>
> Are they some extremely simple tutorials on bindings and wrappers?
> Something with lots of code examples.

I'll use luad as an example.
Luad has both bindings and a wrapper to lua in it.
Primarily you will use the wrapper.

The bindings provide access directly to the c api.
The wrapper makes the API nice to use in D.

A binding is not meant to be nice to use.
It is meant to be equivalent to the original.


More information about the Digitalmars-d-learn mailing list