How can I point an array to existing data in memory while using Better C?
Stijn Herreman
stijn.herreman at outlook.be
Sun Jul 8 21:11:53 UTC 2018
On Sunday, 8 July 2018 at 20:27:34 UTC, Stijn Herreman wrote:
> I should point out that I only have a vague idea of what I'm
> doing, I tried things until it compiled and worked (at first
> glance). If there are any docs that properly explain the
> casting of pointers, I'd appreciate the links.
I found the following works as desired:
environment.d
public __gshared header* GPT_header;
public __gshared partition_entry* GPT_entries;
main.d
GPT_header = cast(header*)0x00007e00;
GPT_entries = cast(partition_entry*)0x00008000;
That still lets me access GPT_entries with an index, e.g.
GPT_entries[0]. Is this how it's supposed to be done, or is there
a better way still?
More information about the Digitalmars-d-learn
mailing list