是否可以在编译时确定实现是否提供精确宽度的整数类型?示例代码(需要):
#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
等
关于c - 是否可以在编译时确定实现是否提供精确宽度的整数类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68522160/