从其他类型的转换Conversions from Other Types

由于 enum 值根据定义属于 int 值,因此 enum 值的转换目标和源与 int 类型的值的相同。Since an enum value is an int value by definition, conversions to and from an enum value are the same as those for the int type. 对于 Microsoft C 编译器,整数与 long 相同。For the Microsoft C compiler, an integer is the same as a long.

Microsoft 专用Microsoft Specific

结构或联合类型之间不允许转换。No conversions between structure or union types are allowed.

任何值都可转换为类型 void,但此类转换的结果只能在将丢弃表达式值的上下文中使用,如在表达式语句中。Any value can be converted to type void, but the result of such a conversion can be used only in a context where an expression value is discarded, such as in an expression statement.

根据定义,void 类型没有值。The void type has no value, by definition. 因此,它不能转换为任何其他类型,并且其他类型不能通过赋值转换为 voidTherefore, it cannot be converted to any other type, and other types cannot be converted to void by assignment. 但是,可显式将值强制转换为类型 void,如类型强制转换中所述。However, you can explicitly cast a value to type void, as discussed in Type-Cast Conversions.

结束 Microsoft 专用END Microsoft Specific

另请参阅See Also

赋值转换Assignment Conversions