uint64_t
类型不能保证在 32 位平台上定义,并且代码如下
int main() {
uint64_t i = 0;
}
可能会导致不完整类型
的编译错误。
是否有预处理器指令来检查 uint64_t
是否存在?还有其他方法可以检查类型是否已定义吗?
最佳答案
我认为合理的方法是检查关联的宏是否UINT64_MAX
已定义,例如
#include <cstdint> /* don't forget to include */
...
#ifdef UINT64_MAX
...
#endif
据我所知,您无法直接检查是否定义了某种类型的同义词。根据 C99,7.18.2 Limits of specified-width integer types(没有 C++ 标准的拷贝来确认,强调我的):
The following object-like macros specify the minimum and maximum limits of the types declared in
<stdint.h>
. Each macro name corresponds to a similar type name in 7.18.1.
关于c++ - 检查是否定义了 uint64_t,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24712091/