[Mesa-dev] [PATCH 04/24] i965: Make 'dw1' and 'bits' unnamed structures in brw_reg.
Matt Turner
mattst88 at gmail.com
Tue Nov 3 12:00:43 PST 2015
On Tue, Nov 3, 2015 at 5:48 AM, Francisco Jerez <currojerez at riseup.net> wrote:
> Matt Turner <mattst88 at gmail.com> writes:
>
>> Generated by
>>
>> sed -i -e 's/\.bits\././g' *.c *.h *.cpp
>> sed -i -e 's/dw1\.//g' *.c *.h *.cpp
>>
>> and then reverting changes to comments in gen7_blorp.cpp and
>> brw_fs_generator.cpp.
>>
>> There wasn't any utility offered by forcing the programmer to list these
>> to access their fields. Removing them will reduce churn in future
>> commits.
>>
>> This is C11 (and gcc has apparently supported it for sometime
>> "compatibility with other compilers")
>>
>> See https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html
>
> This is also used from C++ source where anonymous structs are not part
> of any released standard.
That is true. I have built this series with both clang-3.6 and
gcc-4.4.7. I don't think it's a problem.
> I guess in C++ it would be preferable to
> define accessor methods instead of relying on a language extension --
> That would also allow you to introduce checks making sure that the
> register is of the correct type in order to catch cases in which the
> wrong field of the union is accessed easily.
Maybe. Since I was changing so much code in this series, I wouldn't
want to do that here. Also, having commits that use the brw_reg fields
separately from any accessors seems beneficial.
We could also simply mark fields private with using declarations. That
would get almost all of any potential benefit (of which I'm not sure
how much there is, really).
More information about the mesa-dev
mailing list