Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
3 Views

about -funsigned-bitfields

the document said that -funsigned-bitfieldsDetermines whether the default bitfield type is changed tounsigned. but what is default bitfield type?

thanks in advance.
0 Kudos
3 Replies
Highlighted
Employee
3 Views

By default it is treated as signed int but this may be changed by the -funsigned-bitfields option.

You may learn more on it by following http://gcc.gnu.org/onlinedocs/gcc/Structures-unions-enumerations-and-bit_002dfields-implementation.h...
0 Kudos
Highlighted
3 Views

Hi there,

The default bitfield type signed. Gcc manual gives more details below.


----------
-fsigned-bitfields

-funsigned-bitfields

-fno-signed-bitfields

-fno-unsigned-bitfields

These options control whether a bit-field is signed or unsigned, when the declaration does not use either signed or unsigned. By default, such a bit-field is signed, because this is consistent: the basic integer types such as int are signed types.
----------

Thanks,
Feilong

0 Kudos
Highlighted
3 Views

Thank all.
I got it.
a.c:
struct node
{
int a:2; //no unsigned or signed before int
};
if compiled by icc -funsigned-bitfieds a.c , field a is unsigned int .
if compiled by icc a.c, field a is signed int.
0 Kudos