How to use _Generic with bit-fields
Joseph Myers
joseph@codesourcery.com
Fri Feb 19 22:42:00 GMT 2016
On Fri, 19 Feb 2016, Wink Saville wrote:
> And I've tried to use _Generic to print the type of a bit field but
> the compiler fails with:
Indeed, bit-field types cannot match any type name, only default. The
only conversions applied to the controlling expression are those involved
in lvalue to rvalue conversion (at least, that's what's currently
implemented, and is the current direction on DR#481). In particular, the
integer promotions (which would convert this bit-field to int) are not
applied.
You can of course use unary + (or various other constructs depending on
the set of possible types) to cause some promotions.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Gcc
mailing list