Calling D from C

Steven Schveighoffer schveiguy at yahoo.com
Mon Mar 12 08:00:30 PDT 2012


On Mon, 12 Mar 2012 10:53:09 -0400, Chris W. <wendlec at cd.ie> wrote:

> I have a problem when calling D functions from C. While I can
> perform simple arithmetic operations (i.e. the calculation is
> performed in D and returned to C), I experience problems when
> trying to perform string/char operations or call functions from
> the D standard library (e.g. writefln()). The usual error message
> I get is either "Bus error" or "Segmentation fault". I haven't
> been able to find the reason for this. The programs compile and
> link, however, when run, they terminate with "Bus error" whenever
> a D function is performed within the D code, e.g. something like
> char[] s2 = s.dup; (s is a char* passed from C). Any hint or help
> would be appreciated.
>
> I am using Mac OS X, 10.6.7

If C is running your application startup, you must initialize D's runtime  
 from your C main routine.

-Steve


More information about the Digitalmars-d mailing list