May 22, 2017
On Monday, 22 May 2017 at 18:44:10 UTC, Andrew Edwards wrote:
> Both happen to be the exact same. So does mean that for every function pointer in the file, I need to duplicate as such?

You can use `extern(System)` or that case in D.

It will be extern(Windows) on win an extern(C) elsewhere - just like what the C is doing.


May 23, 2017
On Monday, 22 May 2017 at 18:44:10 UTC, Andrew Edwards wrote:
>
> There isn't any Windows specific section. Every function pointer in the library is decorated in one of the following two forms
>
>     void (APIENTRY *NAME)(PARAMS)
>
> or
>
>     void (APIENTRYP NAME)(PARAMS)

Sorry, I worded that poorly. APIENTRY is defined somewhere in the Win32 headers. IIRC, it's an alias for WINAPI, which is also defined in the Win32 headers to declare the standard call calling convention (which is __stdcall on the MS compiler and something else, I think, on GCC). OpenGL includes windows.h on Windows, so the Win32-specific stuff is there. The functions aren't in any Win32-specific sections.


>
> Both happen to be the exact same. So does mean that for every function pointer in the file, I need to duplicate as such?
>
> version (Windows)
> {
>     extern(Windows)
>     {
>         alias NAME = void function(PARAMS);
>     }
> }
> else
> {
>     extern(C)
>     {
>         alias NAME = void function(PARAMS);
>     }
> }

Adam's answer about extern(System) is the solution. Before it was added, this code is exactly what I had to use in Derelict.


>
> So if I'm understanding correctly, on Windows platforms this:
>
>     typedef void (APIENTRYP PFNGLDISABLEPROC)(GLenum cap);
>     GLAPI PFNGLDISABLEPROC glad_glDisable;
>     #define glDisable glad_glDisable
>
> is technically:
>
>     typedef void (__syscall* PFNGLDISABLEPROC)(GLenum cap);
>     extern "C" PFNGLDISABLEPROC glad_glDisable;
>     #define glDisable glad_glDisable

__stdcall, not __syscall

> which in D is:
>
>     // extern (Windows) obviated by the fact that the following line exports to the C API?
>     extern (C) alias glad_glDisable = void function(GLenum cap);
>     glad_glDisable glDisable;
>

extern(System) for anything cross-platform. If it's something you're using only on Windows, then you can use extern(Windows).


May 23, 2017
On Monday, 22 May 2017 at 18:48:44 UTC, Adam D. Ruppe wrote:
> On Monday, 22 May 2017 at 18:44:10 UTC, Andrew Edwards wrote:
>> Both happen to be the exact same. So does mean that for every function pointer in the file, I need to duplicate as such?
>
> You can use `extern(System)` or that case in D.
>
> It will be extern(Windows) on win an extern(C) elsewhere - just like what the C is doing.

Okay... got it. Thanks.
May 23, 2017
On Tuesday, 23 May 2017 at 00:14:43 UTC, Mike Parker wrote:
> On Monday, 22 May 2017 at 18:44:10 UTC, Andrew Edwards wrote:
>>
>> There isn't any Windows specific section. Every function pointer in the library is decorated in one of the following two forms
>>
>>     void (APIENTRY *NAME)(PARAMS)
>>
>> or
>>
>>     void (APIENTRYP NAME)(PARAMS)
>
> Sorry, I worded that poorly. APIENTRY is defined somewhere in the Win32 headers. IIRC, it's an alias for WINAPI, which is also defined in the Win32 headers to declare the standard call calling convention (which is __stdcall on the MS compiler and something else, I think, on GCC). OpenGL includes windows.h on Windows, so the Win32-specific stuff is there. The functions aren't in any Win32-specific sections.
>
>
[....]

Much appreciated Mike and everyone else. I was able to make a good deal of progress today because of your input.

Andrew
1 2
Next ›   Last »