On Tuesday, 22 October 2024 at 10:50:22 UTC, f wrote:
std.cpp
--
```c
#include \<vector>
#include \<iostream>
#include \<string>

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

s.d
--
```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

In C++, template classes and some STL constructs (e.g. std::basic_string) cannot be directly transferred to D because the compile-time mechanisms for templates in C++ are different from D.

SDB@79

  • interfacing cpp f via Digitalmars-d-learn
    • Re: interfacing cpp Salih Dincer via Digitalmars-d-learn

Reply via email to