delegate memory layout help needed
nobody
nobody at mailinator.com
Wed Feb 14 12:02:03 PST 2007
torhu wrote:
> nobody wrote:
>> More importantly I have been trying to watch two delegate members of a
>> struct to make sure they are getting initialized:
>>
>> printf("&opIndexDg : [%X]\n", opIndexDg );
>> printf(" +0 -> [%X]\n", *(cast(int*)(&opIndexDg)+0) );
>> printf(" +1 -> [%X]\n", *(cast(int*)(&opIndexDg)+1) );
>>
>> printf("&opIndexAssignDg : [%X]\n", &opIndexAssignDg );
>> printf(" +0 -> [%X]\n", *(cast(int*)(&opIndexAssignDg)+0) );
>> printf(" +1 -> [%X]\n", *(cast(int*)(&opIndexAssignDg)+1) );
>>
>> According to what I have seen the delegates in the struct are getting
>> initialized but I keep getting an Array Bounds Error unless I do the
>> exact same assignment done during the initialization afterwards in
>> main(). Am I correctly interpreting the memory layout?
>
> You can access the context pointer with .ptr, and the function pointer
> with .funcptr. See:
>
> http://www.digitalmars.com/d/function.html#closures
Thanks for the suggestion. I realized when I tried to reference .ptr and
.funcptr and the compiler complained that these properties did not exist that I
was still using an older version of DMD. When I upgraded the strange bug
disappeared!
More information about the Digitalmars-d-learn
mailing list