www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - extern(C++) infer linkage from interface?

reply bitwise <bitwise.pvt gmail.com> writes:
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);
}
Apr 22 2015
next sibling parent "bitwise" <bitwise.pvt gmail.com> writes:
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
Apr 24 2015
prev sibling parent reply "Daniel Murphy" <yebbliesnospam gmail.com> writes:
"bitwise"  wrote in message 
news:op.xxishfi24sdys0 nicolass-macbook-pro.local...

 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?
I think there's a bug report about this, somewhere. I'm not sure it's worth changing.
Apr 25 2015
next sibling parent bitwise <bitwise.pvt gmail.com> writes:
On Sat, 25 Apr 2015 09:50:46 -0400, Daniel Murphy  
<yebbliesnospam gmail.com> wrote:

 "bitwise"  wrote in message  
 news:op.xxishfi24sdys0 nicolass-macbook-pro.local...

 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?
I think there's a bug report about this, somewhere. I'm not sure it's worth changing.
Ok, thanks for the info. I was wondering if there was some prohibitive reason that the behavior I'm requesting was not currently in force. I guess I'll dig around in bugzilla then, and file an enhancement request if one does not exist.
Apr 26 2015
prev sibling parent bitwise <bitwise.pvt gmail.com> writes:
On Sat, 25 Apr 2015 09:50:46 -0400, Daniel Murphy  
<yebbliesnospam gmail.com> wrote:

 "bitwise"  wrote in message  
 news:op.xxishfi24sdys0 nicolass-macbook-pro.local...

 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?
I think there's a bug report about this, somewhere. I'm not sure it's worth changing.
For reference: https://issues.dlang.org/show_bug.cgi?id=13867
Apr 26 2015