C-binding external array.

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 9 12:16:42 PDT 2016


On 8/9/16 2:46 PM, ciechowoj wrote:
> On Tuesday, 9 August 2016 at 15:41:08 UTC, Steven Schveighoffer wrote:
>>
>> Well, you can via properties:
>>
>> @property int* tabp() { return tab.ptr; }
>>
>> tabp[elem];
>
> This is nice. The best would be to have it with the same name as
> original symbol, but I can't imagine how it could be done.

D has an answer:

pragma(mangle, "tab")
extern extern(C) int[1] _ctab;

@property int* tab() { return _ctab.ptr; }

I still don't recommend doing this, for previously stated reasons.

-Steve

Disclaimer: D does not always have an answer. It only has MOST of the 
answers.


More information about the Digitalmars-d-learn mailing list