Can not get struct member addresses at compile time

Doeme doeme at the-internet.org
Wed Jun 16 15:48:06 UTC 2021


On Wednesday, 16 June 2021 at 11:56:31 UTC, Mike Parker wrote:
> https://dlang.org/spec/pragma.html#crtctor

Very interesting, thanks for the hint! This is definitely a 
viable solution, though if there's a way to let the linker 
determine the pointer address, that'd be even better.

In C, it's a comparatively standard thing to do:

```c
struct Foo{
     char bar;
};

struct Foo foo;
void *ptr = &foo.bar; //compiles, links and works
```

Why the D compilers would not pass this down to the linker eludes 
me.




More information about the Digitalmars-d-learn mailing list