D can not access C++ class static methods?

zoujiaqing zoujiaqing at gmail.com
Tue Jul 14 10:32:17 UTC 2020


/// Test.hpp

#include <iostream>

class Test
{
     static Test* Create();

     void test();
};


/// Test.cpp

#include "Test.hpp"

Test* Test::Create()
{
     return new Test();
}

void Test::test()
{
     std::cout << "test" << std::endl;
}



/// main.d

import std.stdio;

extern(C++)
{
     class Test
     {
         @disable this();

         static Test Create();

         void test();
     }
}

void main()
{
     Test canvas = Test.Create();

     canvas.test();
}



/// build.sh

clang++ -I./include/ -fPIE -c src/Test.cpp
dmd source/main.d Test.o -L-lstdc++
./main



/// ERROR

# sh build.sh
build.sh: line 4: 59159 Segmentation fault: 11  ./main



More information about the Digitalmars-d mailing list