C++ GCC 支持 long long int 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1523483/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 20:16:31  来源:igfitidea点击:

Does GCC support long long int?

c++cgcc

提问by Polaris878

Does GCC support:

GCC 是否支持:

long long int

which would be a 64-bit integer?

这将是一个 64 位整数?

Also, is long long intpart of the standard?

另外,是long long int标准的一部分吗?

回答by Alex B

Yes GCC does support long long int, which is a part of C99 standard.

是的 GCC 确实支持long long int,这是 C99 标准的一部分。

The standard does not mandate its size in bits, but required values of LLONG_MINand LLONG_MAXin <limits.h>imply it's at least64-bit (exact64-bit wide integer types are int64_t/uint64_tfrom <stdint.h>).

该标准不以位强制它的大小,但所需的值LLONG_MINLLONG_MAX<limits.h>暗示它是至少64位(精确64位宽的整数类型int64_t/uint64_t<stdint.h>)。

  1. LLONG_MINmust be at most -9223372036854775807
  2. LLONG_MAXmust be at least 9223372036854775807
  1. LLONG_MIN必须至多 -9223372036854775807
  2. LLONG_MAX必须至少 9223372036854775807

回答by Chris Lutz

long long intis a part of the C99 standard, and I know GCC supports it. And now I can prove it.

long long int是 C99 标准的一部分,我知道 GCC 支持它。现在我可以证明了。

回答by Mark Rushakoff

On my 32-bit machine,

在我的 32 位机器上,

int main()
{
    printf("%d\n", sizeof(long long int));
    return 0;
}

compiled with gccprints 8 (8 bytes * 8 bits/byte = 64 bits).

编译为gcc打印 8(8 字节 * 8 位/字节 = 64 位)。

回答by DigitalRoss

Yes, long longis part of C99, as well as long longconstants (10222333444555LL) and a few support elements. (LLONG_MAX, llrint(d), llround(d), some others.) And gcc has implemented it for some time now.

是的,long long是 C99 的一部分,还有long long常量 ( 10222333444555LL) 和一些支持元素。( LLONG_MAX, llrint(d), llround(d), 其他一些。) gcc 已经实现了一段时间了。

回答by eyalm

In order to print long long int variables:

为了打印 long long int 变量:

long long int lli = 100000000;

printf("%lld\n", lli);

回答by Lee B

long longs are well supported, and have been for a long long time [sorry]. As I understand it, this should have been 128 bit on 64-bit platforms, but for compatibility/portability reasons in GCC, has standardised on a 64-bit width.

多头得到了很好的支持,并且已经支持了很长时间[抱歉]。据我了解,这在 64 位平台上应该是 128 位,但出于 GCC 中的兼容性/可移植性原因,已标准化为 64 位宽度。

See also: (u)int128_t, and this discussion on GCC's 128-bit integer support

另请参阅:(u)int128_t,以及关于 GCC 的 128 位整数支持的讨论

回答by Marc W

I believe that usually an unsigned long longis the traditional representation of a 64-bit integer. I'm assuming long long intwould work too, but I've never personally seen any 64-bit vars declared that way before.

我相信通常 anunsigned long long是 64 位整数的传统表示形式。我假设它long long int也能工作,但我个人以前从未见过任何以这种方式声明的 64 位变量。