Calling C++ code with pointer** argument
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 1 00:17:04 PDT 2016
On Wednesday, 1 June 2016 at 07:09:16 UTC, abad wrote:
> D source:
>
> extern(C++) void thisWorks(const char* test);
> extern(C++) void doesNotLink(const char** test);
>
> void main() {
> char* baz1;
> char** baz2;
> thisWorks(baz1);
> doesNotLink(baz2);
> }
>
> CPP source:
>
> #include <stdio.h>
>
> void thisWorks(const char* test) {
> printf("hi\n");
> }
>
> void DoesNotLink(const char** test) {
> // not reached
> }
>
> The error given by the linker:
> test.d:(.text._Dmain+0x21): undefined reference to
> `doesNotLink(char const* const*)'
>
> What's happening? I know there are differences in const
> behavior between D and C++, but can't figure a way around it.
> Any sort of casting trick I tried doesn't seem to help.
Try this:
extern(C++) void DoesNotLink(const(char)**);
More information about the Digitalmars-d-learn
mailing list