How to use a function without their sources

nazriel spam at dzfl.pl
Fri Jan 18 13:09:26 PST 2013


On Friday, 18 January 2013 at 20:33:04 UTC, Andrej Mitrovic wrote:
> On 1/18/13, nazriel <spam at dzfl.pl> wrote:
>> Show me a working solution to question from first post.
>>
>> "How to use existing static D library *WITHOUT* using .DI 
>> files".
>> You can't edit library itself, so adding extern(C) to functions
>> won't work.
>> You can't create .DI file - which is the main question from 
>> first
>> post.
>
> That formulation makes no sense. If it's not his library the 
> provider
> will either give the .d files or autogenerated/handwritten .di 
> files.
> He won't just get a naked static library without supporting 
> files.
>
> And if he controls the library, he will either have to 
> autogenerate
> .di files, or handwrite them. Even if he uses extern(C) he will 
> still
> have to provide a .d file with all extern(C) functions and 
> types.

Still doesn't answers question from first post.

So let me quote it for you:
"Is there a way to use a function from a static D library without 
importing their D sources nor their DI interface?"

There were 2 types of answers in this topic:
1) Yes, you can if functions in library are marked as extern(C)
2) Yes, you can even if functions are not marked as extern(C) 
with little hack which is dumping object file.

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


More information about the Digitalmars-d-learn mailing list