c++ - Why SWIG C# overloads fail? -


so having simple code in c++. having c++ library with:

class a{ public:     virtual void call();     virtual void callcall();     virtual ~a(); }; 

and swig file:

%{ #include "a.h" %}  %include "a.h"  %module(directors="1") testswig;  %feature("director") a; 

after calling swig generator, including generated c++ , c# files related projects , rebuilding projects.

swig.exe -c++ -csharp -namespace testswig -outdir ./sharp/testswig -o ./testswig.cxx testswig.i

we want simple c# .net code work:

using system; using testswig;  namespace asharp {     class cassa : a{         public override void call() {             console.writeline("hello c#");         }     }      class program {         private static void main(string[] args) {             var c = new cassa();             c.callcall();             console.readline();         }     } } 

yet see c++ implementation 1 gets called

void a::call() {     std::cout << "hello c++ world!" << std::endl; } 

now question is: do wrong inheritance , virtual functions not work?

and answer was... swig->examples!=) problem in ordering in .i file.

%module(directors="1") testswig; // module name  // source code refrence %{ #include "a.h" %}  %feature("director") a; // objects support inheritance %include "a.h" // main file parse 

and worked required!=)


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -