Re: int64_t == long long

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/1/08 2:17 PM, "Yang Zhang" <yanghatespam@xxxxxxxxx> wrote:

> Hi, why isn't int64_t == long long at least on 64-bit x86 Linux?

Because int64_t should be 64-bit, but long long could be 64-bit or larger.

#include <stdint.h> // from C99
#include <climits>

cout << (sizeof(int64_t) * CHAR_BIT) << endl;
cout << (sizeof(long long) * CHAR_BIT) << endl;

You can also do this:

#include <stdint.h> // from C99
#include <typeinfo>

cout << typeid(int64_t).name() << endl;
cout << typeid(long long).name() << endl;

> How do I tell what type this actually is?

typeid

> And are literals ending with LL always long long?

Yes, that's what the LL suffix means.

So the literal integer numerics are:
'A'
L'A'
65
65L
65LL
65U
65UL
65ULL

Keep in mind the portability issues surrounding use of long long, LL, and
ULL.  You may want to use the <stdint.h> INT64_C and UINT64_C macros to
construct your numeric literals.

INT64_C(65)
UINT64_C(65)

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux