On Tue, Sep 14, 2010 at 1:27 AM, Jan Ceuleers <[email protected]>wrote:

> On 11/09/10 17:49, Bond wrote:
>
>> (type *)( (char *)__mptr - offsetof(type,member) );})
>>
>> there a subtraction has been done why is this subtraction done?
>>
>
> Not having read any of the documentation, what comes to mind is this:
>
> if __mptr is a pointer to the member of a structure, the above expression
> returns a pointer to the first byte of the containing structure, typecast to
> the type of the structure.
>
> Example:
>
> typedef struct {
>        int a;
>        char b;
> } test_t;
>
> test_t test;
>
> Now assume that __mptr is a pointer to test.b, then the above expression
> returns a pointer to test, i.e. a pointer to the structure that b is a
> member of.
>
> Jan
>
> Hi,
Jan no problem I am clear with the original question that I had asked with
Manohar.

Reply via email to