std.cpp
--
#include \<vector>
#include \<iostream>
#include \<string>

    using namespace std;
    void a(string a)
    {
                  cout\<\<" hello " \<\<a\<\<endl;
    }

s.d
--
module s;

import core.stdcpp.string;

    extern(C++)
    {
        final void a(basic_string!char a);
    }

    main.d
    --
    void main()
    {
         import s;
      import core.stdcpp.string;
      auto i=basic_string!char("hello");
        a(i);
    }

i've read the interfacing cpp on documentation,
ok then the compiler mesasge for this

libstdc++ std::__cxx11::basic_string is not yet supported; the struct contains an interior pointer which breaks D move semantics!

but with options AA="-D_GLIBCXX_USECXX11_ABI=0" on g++ ,
and BB="-version=_GLIBCXX_USE_CXX98_ABI" on dmd the message is :

Error: undefined reference to `a(std::string)`

how to solve the, std:string , std:vector,  std:optional ?

is there any article / links on general interfacing c++ problem solving ?

thanks
  • interfacing cpp f via Digitalmars-d-learn

Reply via email to