数据类型说明符和等效项Data Type Specifiers and Equivalents

本书通常使用下表中所列的类型说明符的形式而不使用长形式,并且本书假设 char 类型在默认情况下有符号。This book generally uses the forms of the type specifiers listed in the following table rather than the long forms, and it assumes that the char type is signed by default. 因此,在本书中,charsigned char 等效。Therefore, throughout this book, char is equivalent to signed char.

类型说明符和等效项Type Specifiers and Equivalents

类型说明符Type Specifier 等效项Equivalent(s)
signed char1signed char1 charchar
signed intsigned int signedintsigned, int
signed short intsigned short int shortsigned shortshort, signed short
signed long intsigned long int longsigned longlong, signed long
unsigned charunsigned char
unsigned intunsigned int unsignedunsigned
unsigned short intunsigned short int unsigned shortunsigned short
unsigned long intunsigned long int unsigned longunsigned long
floatfloat
long double2long double2

1 当在默认情况下将 char 类型设为无符号时(通过指定 /J 编译器选项),无法将 signed char 缩写为 char1 When you make the char type unsigned by default (by specifying the /J compiler option), you cannot abbreviate signed char as char.

2 在 32 位和 64 位操作系统中,Microsoft C 编译器将 long double 映射到类型 double2 In 32-bit and 64-bit operating systems, the Microsoft C compiler maps long double to type double.

Microsoft 专用Microsoft Specific

可以指定 /J 编译器选项来将默认 char 类型从有符号更改为无符号。You can specify the /J compiler option to change the default char type from signed to unsigned. 当此选项生效时,charunsigned char 的意义相同,必须使用 signed 关键字来声明有符号字符值。When this option is in effect, char means the same as unsigned char, and you must use the signed keyword to declare a signed character value. 如果将 char 值显式声明为有符号,则 /J 选项不会影响它,并且当其类型扩展为 int 类型时,该值将进行符号扩展。If a char value is explicitly declared signed, the /J option does not affect it, and the value is sign-extended when widened to an int type. 当扩展到 char 类型时,int 类型为零扩展。The char type is zero-extended when widened to int type.

结束 Microsoft 专用END Microsoft Specific

请参阅See Also

C 类型说明符C Type Specifiers