提交 919ad8d5 编写于 作者: R Rich Felker

explicitly use signed keyword to define intNN_t and derivative types

standing alone, both the signed and int keywords identify the same
type, a (signed) int. however the C language has an exception where,
when the lone keyword int is used to declare a bitfield, it's
implementation-defined whether the bitfield is signed or unsigned. C11
footnote 125 extends this implementation-definedness to typedefs, and
DR#315 extends it to other integer types (for which support with
bitfields is implementation-defined).

while reasonable ABIs (all the ones we support) define bitfields as
signed by default, GCC and compatible compilers offer an option
-funsigned-bitfields to change the default. while any signed types
defined without explicit use of the signed keyword are affected, the
stdint.h types, especially intNN_t, have a natural use in bitfields.
ensure that bitfields defined with these types always have the correct
signedness regardless of compiler & flags used.

see also GCC PR 83294.
上级 eb5ae940
......@@ -7,10 +7,10 @@ TYPEDEF _Addr regoff_t;
TYPEDEF _Reg register_t;
TYPEDEF signed char int8_t;
TYPEDEF short int16_t;
TYPEDEF int int32_t;
TYPEDEF _Int64 int64_t;
TYPEDEF _Int64 intmax_t;
TYPEDEF signed short int16_t;
TYPEDEF signed int int32_t;
TYPEDEF signed _Int64 int64_t;
TYPEDEF signed _Int64 intmax_t;
TYPEDEF unsigned char uint8_t;
TYPEDEF unsigned short uint16_t;
TYPEDEF unsigned int uint32_t;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册