How to use a function without their sources

Andrej Mitrovic andrej.mitrovich at gmail.com
Fri Jan 18 15:50:22 PST 2013


On 1/18/13, nazriel <spam at dzfl.pl> wrote:
> There were 2 types of answers in this topic:
> 1) Yes, you can if functions in library are marked as extern(C)

You still have to provide .d or .di files, you can't expect the user
to have to manually write extern declarations.

> 2) Yes, you can even if functions are not marked as extern(C)
> with little hack which is dumping object file.

That little hack is not very reliable. And once Pull 1085 is merged
that technique will become completely unreliable.
(https://github.com/D-Programming-Language/dmd/pull/1085).

> Whatever you think it is *terrible* idea or not, it seems to be
> the only one working idea in this, specific scenario.

The terrible idea is using the mangled representation of a D function
but calling it as an extern(C) function. This will simply not work
properly.

Using extern(C) properly is fine, of course. However even that is
problematic because extern(C) does not allow you to overload functions
and you'll have 64bit breakage due to
http://d.puremagic.com/issues/show_bug.cgi?id=5570.


More information about the Digitalmars-d-learn mailing list