海湾合作委员会,宽长整型不同架构 [英] gcc, width of long int on different architectures
问题描述
在64位架构,长整型
,根据GCC是至少的int64_t
。在32位,长整型
至少 int32_t
。随着微软的编译器,长
始终是一个 int32_t
,不论32/64位。有没有什么办法:
- 强制GCC对待只要一个的int64_t,在32位? (为便于测试)
- 强制GCC治疗,只要在64位一个int32_t? (是否符合MS的编译器)。
不这样做 - 使用标准类型,如 int32_t
, uint32_t的
,的int64_t
, uint64_t中
等从< stdint。 H>
,而不是试图做出赤裸裸的类型,如长整型
或试图弯曲编译你的意愿假设
注:64位模式对于任何给定的平台(例如,LP64大多数* nix平台,Mac OS X的,等等)是给定的,因此,即使你能说服编译器使用不同的64位模式,你可能会打破任何调用系统code,图书馆等。
On 64-bit architectures, long int
, according to gcc is at least an int64_t
. On 32-bit, long int
is at least int32_t
. With Microsoft compilers, long
is always an int32_t
, regardless of 32/64-bit. Is there any way to:
- Force gcc to treat long as a int64_t, on 32bit? (for ease of testing)
- Force gcc to treat long as a int32_t on 64bit? (for compliance with MS's compiler).
Don't do this - use standard types such as int32_t
, uint32_t
, int64_t
, uint64_t
, etc from <stdint.h>
rather than trying to make assumptions about naked types such as long int
or trying to bend the compiler to your will.
Note: The 64-bit model for any given platform (e.g. LP64 for most *nix platforms, Mac OS X, etc) is a given, so even if you could convince the compiler to use a different 64-bit model you would probably break any calls to system code, libraries, etc.
这篇关于海湾合作委员会,宽长整型不同架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!