This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re:Re: [gcc plugin] get member offset in struct just like offsetof
- From: dotpy <dotpy2 at 163 dot com>
- To: "Eric Botcazou" <ebotcazou at adacore dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 7 Feb 2018 23:20:27 +0800 (CST)
- Subject: Re:Re: [gcc plugin] get member offset in struct just like offsetof
- Authentication-results: sourceware.org; auth=none
- References: <79a21353.8b8a.1616bb84efc.Coremail.dotpy2@163.com> <1571160.eJiUTSahzf@polaris>
Hi Eric,
Thank you very much. Your advise is exact right. :)
The function bit_position and byte_position is what I want to implement offsetof.
Regards
At 2018-02-07 00:58:17, "Eric Botcazou" <ebotcazou@adacore.com> wrote:
>> I am writing a gcc plugin for parsing the structure fields. But I have the
>> problem how to get the offset of each field in the struct? Just like the
>> offsetof macro in gcc.
>>
>> I see DECL_FIELD_OFFSET in tree.h, but the result seems not right.
>
>The offset in bits/bytes is given by tree.c:bit_position/byte_position.
>
>--
>Eric Botcazou