nomad-software / x11

Bindings to X11 for the D programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ldc does not accept both XCreateWindow

rikkimax opened this issue · comments

LDC - the LLVM D compiler (0.14.0):
based on DMD v2.065 and LLVM 3.4.2
and
LDC - the LLVM D compiler (0.15.0-beta1):
based on DMD v2.066.1 and LLVM 3.5.0

Works fine for dmd 2.066.1, dmd 2.065 and gdc-4.8.2.

../../../.dub/packages/x11-1.0.1/source/x11/Xlib.d(1554): Error: Function type does not match previously declared function with the same mangled name: XCreateWindow

ldc 0.15.1 still doing it as well.

LDC - the LLVM D compiler (0.15.1):
based on DMD v2.066.1 and LLVM 3.5.0

If this works fine for dmd 2.066.1, dmd 2.065 and gdc-4.8.2 i suspect it's an issue with ldc. I don't have it installed so i can't test. Maybe post this also in the ldc forum? http://forum.dlang.org/group/digitalmars.D.ldc

It is indeed an issue with ldc, however I would expect this behaviour on all compilers.
Different signature same mangling makes me rather uncomfortable.

I'll post to D newsgroup as I believe this should be intended behaviour on all compilers.

Ah right, i see what you mean.

Iain Buclaw more or less confirmed its a DMD-FE bug.
Filed https://issues.dlang.org/show_bug.cgi?id=13896

Ok thanks, what would suggestions be to fix this binding?

I'm thinking along the lines of:
extern(D) void XCreateWindow(...) {
XCreateWindow(cast(..)arg1, ...);
}

Can't remember exact signature, but do that for one of them. Theoretically it should get inlined and completely optimized out.

I've removed the offending function as it was only added as a convenience in commit 7705bc5 and it's not a standard xlib function.

Also the signatures where not compatible as the non-standard function used XID which is a c_ulong (which can be 32 or 64bit dependant on OS and architecture) and the standard function uses a pointer to a struct (Visual*). I'll leave it to devs to make the cast themselves instead of hiding it in a non-standard function.

If people still need to use it they can use the last x11 release version but i doubt it's necessary.

I have some bad news.
../../../.dub/packages/x11-1.0.3/source/x11/Xlibint.d(896): Error: Function type does not match previously declared function with the same mangled name: Data

That seems to have been a bug in Xlibint.d where the function was duplicated. It should be fixed now, see: e1573bd Please try again.

Great thanks, working fine for ldc.
Unfortunately for some reason gdc seems to have broken however.
https://travis-ci.org/Devisualization/window/jobs/45249387

../../../.dub/packages/x11-1.0.4/libx11.a: In function Data16': /home/travis/build/Devisualization/window/../../../.dub/packages/x11-1.0.4/source/x11/Xlibint.d:638: undefined reference toData'

This can only be caused by libx11 not being linked or the reference is not contained in that lib. The above bugfix removes the Data function (via static if) as it was ported from a macro and relies on the external reference being there. i.e. https://github.com/nomad-software/x11/blob/master/source/x11/Xlibint.d#L896

I guess we could change the enum here: https://github.com/nomad-software/x11/blob/master/source/x11/Xlibint.d#L193 to enable the function and disable looking for the external reference. Hopefully the function and the external reference perform the same task?

What do you think?

I've changes the default from being an external reference (which apparently is only available on Cray systems) to use the defined function. This looks like an error made during the porting of the C headers. All should be fixed now, please give it a try.

I'm closing this as I guess it worked?