是否可以在编译时确定一个实现是否提供精确宽度的整数类型?
Is it possible to determine at compile time whether an implementation provides exact-width integer types?
是否可以在编译时确定一个实现是否提供精确宽度的整数类型?示例代码(需要):
#include <stdint.h>
#if HAS_EXACT_WIDTH_INTEGER_TYPES
uint32_t i;
#else
/* handle the case */
#endif
问题原因:编写可修改的代码,如果实现不提供精确宽度的整数类型,则不会导致编译时错误。
- For each type described herein that the implementation provides, 261)
<stdint.h>
shall declare that typedef name and define the associated macros. Conversely, for each type described herein that the implementation does not provide, <stdint.h>
shall not declare that typedef
name nor shall it define the associated macros. An implementation shall provide those types described as ''required'', but need not provide any of the others (described as ''optional'').
即uint32_t
存在iff#defined UINT32_MAX
等
是否可以在编译时确定一个实现是否提供精确宽度的整数类型?示例代码(需要):
#include <stdint.h>
#if HAS_EXACT_WIDTH_INTEGER_TYPES
uint32_t i;
#else
/* handle the case */
#endif
问题原因:编写可修改的代码,如果实现不提供精确宽度的整数类型,则不会导致编译时错误。
- For each type described herein that the implementation provides, 261)
<stdint.h>
shall declare that typedef name and define the associated macros. Conversely, for each type described herein that the implementation does not provide,<stdint.h>
shall not declare thattypedef
name nor shall it define the associated macros. An implementation shall provide those types described as ''required'', but need not provide any of the others (described as ''optional'').
即uint32_t
存在iff#defined UINT32_MAX
等