为什么 INTEGRAL_MAX_BITS 会返回小于 64 的值? [英] Why would INTEGRAL_MAX_BITS ever return a value less than 64?

查看:28
本文介绍了为什么 INTEGRAL_MAX_BITS 会返回小于 64 的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试弄清楚我可以为 Windows 宏 _INTEGRAL_MAX_BITS 提供哪些值.
MSDN 的 __int64 文档 说这每当使用 __int64

I'm trying to figure out what values I can expect for the Windows macro _INTEGRAL_MAX_BITS.
MSDN's __int64 documentation says that this code should be used whenever using __int64

#if defined (_INTEGRAL_MAX_BITS) && \
      _INTEGRAL_MAX_BITS >= 64
    typedef signed __int64 int64;
    typedef unsigned __int64 uint64;
#else
    #error __int64 type not supported
#endif

为什么我会看到 INTEGRAL_MAX_BITS 的值低于 32?this 中的答案问题表明在 32 位 Windows 上,long long 是 64 位.VS2013 文档 指出

Why would I ever see a value below 32 for INTEGRAL_MAX_BITS? The answers in this question show that on 32 bit Windows, a long long is 64 bits. VS2013 documentation states that

_INTEGRAL_MAX_BITS - 将整数类型的最大大小(以位为单位)报告为整数文字.

_INTEGRAL_MAX_BITS - Reports the maximum size (in bits) for an integral type as an integer literal.

由于long long是整数类型,所以应该返回的最小值,即使在32位Windows上,也是64位,对吗?
为什么需要 #if_INTEGRAL_MAX_BITS >= 64 部分?

Since long long is an integral type, the lowest value that should be returned, even on 32 bit Windows, is 64 bits, right?
Why is the _INTEGRAL_MAX_BITS >= 64 portion of the #if necessary?

推荐答案

该文档适用于 Visual Studio 6.0.Visual Studio 6.0 于 1998 年发布,在任何 long long 标准化之前,并且不支持它.它确实支持您在文档中看到的 __int64,因此可以无条件地使用 ,但大概对 _INTEGRAL_MAX_BITS 的检查是为了获得更好的甚至更旧版本的 Visual Studio 的错误消息.不支持__int64 类型"是一条有用的错误消息.诸如意外标记 'int64' 之前的语法错误"之类的内容不是有用的错误消息.

That documentation is for Visual Studio 6.0. Visual Studio 6.0 was released in 1998, which was before any long long was standardised, and did not support it. It did support the __int64 you see in the documentation, so that could be unconditionally used, but presumably the check on _INTEGRAL_MAX_BITS is to get a better error message for even older versions of Visual Studio. "__int64 type not supported" is a useful error message. Something like "syntax error before unexpected token 'int64'" is not a useful error message.

这篇关于为什么 INTEGRAL_MAX_BITS 会返回小于 64 的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆