extern(C++, NS)

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Sun Nov 29 02:33:14 PST 2015


On 29 Nov 2015 10:57 am, "Manu via Digitalmars-d" <
digitalmars-d at puremagic.com> wrote:
>
> On 29 November 2015 at 19:42, Manu <turkeyman at gmail.com> wrote:
> > On 29 November 2015 at 16:14, Manu <turkeyman at gmail.com> wrote:
> >> Upon further wasting-my-time, I am starting to suspect the forward
> >> referencing issue may be a bigger problem than it appears.
> >> I have lots of aliases, and most of them work, but some of them just
> >> don't; "Error: identifier 'Kernel' of 'ep.Kernel' is not defined" (not
> >> a very helpful message). It is though, it's defined right next to it's
> >> companion, which is declared at the same time, in the same place, but
> >> I don't get an error for that one. I think the problem here is that
> >> the companion symbol isn't involved in a cross-module reference.
> >>
> >> I try and reduce the problem, but it always disappears. It only
> >> appears when the number of modules and interaction between them
> >> becomes sufficient.
> >> I suspect that whatever it is that causes namespace forward
> >> referencing to fail may also be leading to this problem... just a
> >> hunch, but it's the best I've got.
> >
> >
> > Progress... now when I compile, I get a pop-up dialog box that says:
> > "object.Error@(0): assert(0) or HLT instruction", and then writes
> > "ICE: unsupported type const(char)[]" to the output.
>
> So, I think this compiler crash is when trying to C++ mangle types
> that it doesn't know how to deal with...
> interestingly, one of those types is typeof(null), which should work,
> and be mangled as nullptr_t ?
> Any slice type (ie, char[]) used anywhere within any scope attributed
> extern(C++) seems to cause DMD to crash.
>

Correct, you will also get the same message with shared or immutable types,
and static arrays.  And I will hazard a guess at delegates and lazy
parameters too.

There is no technical limitation for this, you *can* pass these data
structures to C/C++ (except shared and immutable) so long as the struct
layout is matching on the other side.  At the same time, it may be for the
best if you pass the ptr and length explicitly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20151129/0684a3f1/attachment-0001.html>


More information about the Digitalmars-d mailing list