What is the wrong with my C++ interfacing
drug
drug2004 at bk.ru
Mon Mar 16 07:46:00 UTC 2020
On 3/16/20 10:11 AM, Ferhat Kurtulmuş wrote:
> On Sunday, 15 March 2020 at 22:25:27 UTC, Arine wrote:
>> On Sunday, 15 March 2020 at 21:27:32 UTC, Ferhat Kurtulmuş
>
>> extern(C++, cv){
>> extern(C++, class) struct Size_(_Tp){
>> @disable this();
>> ~this() { }
>>
>> final _Tp area() const;
>> final double aspectRatio() const;
>> final bool empty() const;
>>
>> _Tp width; //!< the width
>> _Tp height; //!< the height
>> }
>> }
>>
>> extern(C++){
>> cv.Size_!int* createSizeIntWH(int w, int h);
>> }
>>
>> void main()
>> {
>> Size_!int* sz = createSizeIntWH(200, 100);
>> writeln(sz.width);
>> }
>
> This worked for me too. But member functions are still causing linker
> error. It seems like docs (https://dlang.org/spec/cpp_interface.html) do
> not cover those situations. Is there any other sources to read for it.
> Maybe you make a pull request to docs covering C++ interfacing tips in
> detail.
Not tested:
extern(C++, class) struct Size_(_Tp){
@disable this();
~this() { }
extern(C++): // <- IIRC linkage should be set for members separately
from aggregate
final _Tp area() const;
final double aspectRatio() const;
final bool empty() const;
_Tp width; //!< the width
_Tp height; //!< the height
}
More information about the Digitalmars-d-learn
mailing list