Can not get struct member addresses at compile time
Ali Çehreli
acehreli at yahoo.com
Wed Jun 16 23:20:26 UTC 2021
On 6/16/21 3:27 PM, Doeme wrote:
> On Wednesday, 16 June 2021 at 22:16:54 UTC, H. S. Teoh wrote:
>> The compiler does not (and cannot) know. But the runtime dynamic
>> linker can, and does. The two are bridged by the compiler emitting a
>> relocatable symbol for the address of the global variable, with a
>> table of relocations (offsets in the code) that the runtime linker
>> patches the actual addresses into when the program is executed.
>>
>>
>> T
>
> Exactly! Except that the dynamic linker is not really involved here,
> since all the symbols can/must be relocated statically at link time.
Thank you, both. It still rules out an address at "compile time" in
general. For example, we cannot use such an address when instantiating a
template, or static array length, etc.
And if I understand it correctly, there must be a pointer *variable* for
the linker to initialize. Fine then: That's how this usage works for C
but not for D. :)
Thank you,
Ali
More information about the Digitalmars-d-learn
mailing list