Derelict Problems with DMD 1.018
DerelictAL/GL/GLU/IL/ILU/ILUT all have one thing in common: the functions they bind to on the C side have the __stdcall calling convention on Windows and the regular C calling convention on other platforms. As a result, the function pointers in D need to be declared as extern(Windows) on Windows and extern(C) on other platforms.
In order to avoid duplicating the function pointer declarations, they were implemented this way:
version(Windows)
extern(Windows):
else
extern(C):
// function declarations go here
In DMD 1.018, Walter fixed a long standing DMD bug that had to do with version statements. The fix broke the above code, causing the affected Derelict modules to fail compilation. The Derelict fix seemed simple:
version(Windows)
{
extern(Windows):
}
else
{
extern(C):
}
// function declarations go here
Version statements do not create a new scope, so the effect should have been the same as the original code. As expected, it compiles fine. However, the problem manifests itself in a different form: the extern statements are having no effect on the function declarations. As a result, the compiled executables are crashing on both Windows and Linux.
I tested to be sure the version statements are working as expected and not creating a new scope. So now it seems quite obvious (based on the original bug report) that the problem has to do with the colon following the extern statements.
The way I can see to work around the problem is to add the appropriate extern statement to each function pointer declaration, meaning two of each. That's not going to happen. So I'm filing a bug report and hoping it gets fixed in the very near future.
Meanwhile, if you are using one of the affected packages, you'll need to stick with DMD 1.017 or earlier. Again, this is only for the packages listed above. The other packages, such as the DerelictSDL* stuff, are not affected.
Technorati Tags: D Programming Language, DMD, Derelict