Calling C++ code with pointer** argument

abad via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 1 00:09:16 PDT 2016


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.



More information about the Digitalmars-d-learn mailing list