【MSVC】http://msdn.microsoft.com/en-us/library/aa261215(v=vs.60).aspx
允许使用64位的整数
使用之前先判断是否支持64位整数
【GGC】_#if defined (_INTEGRAL_MAX_BITS) && \ _INTEGRAL_MAX_BITS >= 64 typedef signed __int64 int64; typedef unsigned __int64 uint64; #else #error __int64 type not supported #endif
http://bytes.com/topic/c/answers/214990-defining-int64
I use this in my code #if defined(_MSC_VER) || defined(__BORLANDC__) typedef unsigned __int64 ulong64; typedef signed __int64 long64; #else typedef unsigned long long ulong64; typedef signed long long long64; #endif It works for GCC, MSVC and BorlandC which will cover the vast majority of platforms.
The _ _int64 keyword declares a new type, a 64-bit (8-byte) integer. As with the int, short, andlong types, the _ _int64 type has a corresponding unsigned version, so the _ _int64 keyword actually can be used to create two types.
The following code sample shows how to declare two 64-bit integers, one signed and the other unsigned:
__int64 signed_big_int;
unsigned __int64 unsigned_big_int;
In the printf family of run-time library functions, the format for optional prefixes includes I64, in addition to F, N, h, l, and L. For example, the following statement includes an example of a valid format string:
printf("%I64d", x);
When manipulating 64-bit integers, no special functions are necessary. Ordinary arithmetic operators and operations behave as expected.
Note Both the Alpha edition and the x86 edition of Visual C++ support the _ _int64 data type. However, the support in the Alpha edition is more complete; in particular, the integrated debugger recognizes _ _int64 variables in the Alpha edition but not in the x86 edition. Also, both editions provide full support for the _ _int8, _ _int16, and _ _int32 types. Use of these types is not recommended, except in situations where the program must interact with a fixed-byte layout (for example, in reading records previously stored on disk).
Use of _ _int64 should be conditional on the predefined macro _INTEGRAL_MAX_BITS. This macro describes the maximum size of integers defined using the form _ _intx. For example:
_#if defined (_INTEGRAL_MAX_BITS) && \
_INTEGRAL_MAX_BITS >= 64
typedef signed __int64 int64;
typedef unsigned __int64 uint64;
#else
#error __int64 type not supported
#endif