문제

My gcc compiler allows me to define an unsigned long long (i.e. 64-bit) literal as

#define A_LITERAL 0x1ull

--- or ---

#define A_LITERAL 0x1llu

Is there any difference between these two literal statements. Is this common to other C compilers?

도움이 되었습니까?

해결책 2

Both are allowed by the C standard (section 6.4.4.1).

The unsigned suffix u can be before or after the long l (or long long (ll)) suffix.

다른 팁

Both are the same: excerpt from n3337 draft of C++11 standard:

integer-suffix:
    unsigned-suffix long-suffix(opt)
    unsigned-suffix long-long-suffix(opt)
    long-suffix unsigned-suffix(opt)
    long-long-suffix unsigned-suffix(opt)

unsigned-suffix: one of
    u U

long-suffix: one of
    l L

long-long-suffix: one of
    ll LL

ull or llu force the compiler to treat a constant as an unsigned and long long integer.
The order of ll and u doesn't matter, nor their case. you may also write LLU or ULL.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top