How to use std. packages in so files written in dlang
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Aug 11 18:40:04 PDT 2016
On Friday, 12 August 2016 at 00:57:42 UTC, grampus wrote:
> Hi,erveryone
> I am trying to use dLang to make so file for existing c/c++
> project.
> I followed the examples on https://dlang.org/dll-linux.html,
> which works well.
>
> but when I replaced import core.stdc.stdio; with import
> std.stdio;
> to use writefln() instead of printf(), then things changed.
>
To expand on ketmar's answer, support for some language features
exists in D Runtime. If you never use those features directly or
indirectly (which means limiting yourself to the C API, avoiding
anything that touches the GC, no associative arrays, and so on)
then you don't need to initialize D runtime. That's why you don't
see the problem when calling printf, but writeln uses features
internally that require the D Runtime and so you get the error
when you execute the program.
More information about the Digitalmars-d-learn
mailing list