gpt4 book ai didi

c - 是否可以在编译时确定实现是否提供精确宽度的整数类型?

转载 作者:行者123 更新时间:2023-12-02 02:05:11 25 4
gpt4 key购买 nike

是否可以在编译时确定实现是否提供精确宽度的整数类型?示例代码(需要):

#include <stdint.h>

#if HAS_EXACT_WIDTH_INTEGER_TYPES
uint32_t i;
#else
/* handle the case */
#endif

问题的原因:编写适应性强的代码,如果实现不提供精确宽度的整数类型,则不会导致编译时错误。

最佳答案

C11/C17 7.20p4 :

  1. 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

关于c - 是否可以在编译时确定实现是否提供精确宽度的整数类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68522160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com