Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

about -funsigned-bitfields

chenghuiming_bjgmail
390 Views

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
Om_S_Intel
Employee
390 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.html
0 Kudos
Feilong_H_Intel
Employee
390 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
chenghuiming_bjgmail
390 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
Reply