当出现在 c++98 或更高版本的实现中(我知道 C++11 已经提供了 64 位 int)时,我想通过 int64_t 为我的 int 获利。 是否有一种可移植和通用的方法来检查 int64_t 的存在,或者 - 甚至更好 - 任何可用的 64 位或更高整数类型,如:
#ifdef has_int64_t
typedef int64_t myint
#else
typedef int myint
#endif
//...code
myint a;
如果可能,检查应该适用于 c++98、c++03 和 c++11。
最佳答案
很确定这应该可以使用 stdint.h:
#ifdef INT64_C
//...
#else
//...
#endif
关于c++ - 检查非可移植整数类型是否存在的可移植方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8422919/