extern(C++) infer linkage from interface?

bitwise via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 24 14:09:27 PDT 2015


On Thursday, 23 April 2015 at 00:47:30 UTC, bitwise wrote:
> I have a class with callbacks that can be overridden, which are 
> inherited from an extern(C++) interface. The callbacks are 
> called from C++ code. Is there any chance that the linkage will 
> be inferred in the future?
>
> To be clear, couldn't the extern(C++) just be inferred in the 
> class 'MyTest' below?
>
> extern(C++) {
>     interface Test {
>         void Foo();
>     }
>
>     void register(Test test);
>     void unregister(Test test);
> }
>
> class MyTest : Test {
>     extern(C++) {     // seemingly unnecessary boilerplate
>         void Foo() {
>             writeln("foo");
>         }
>     }
> }
>
> void main() {
>     MyTest test = new MyTest();
>     register(test);
>     while(...) {}
>     unregister(test);
> }

Bump


More information about the Digitalmars-d mailing list