Re: __typeof__ (const int)

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

 



On 2017-02-16 22:54 +0800, Xi Ruoyao wrote:

> According to the Standard, '32768' is a decimal literal, but '-32768'
> is not. It's an expression using unary '-' to the literal '32768'.
> Here '32768' has type int32_t. So the expression also has type
> int32_t despite the result can fit into an int16_t.

It's called 'literal' in C++ Standard. In C Standard it's just called
integer constant.

For example, in C99 6.4.4.1 the grammar of decimal-constant is:

    decimal-constant:
        nonzero-digit
        decimal-constant digit

We can see a decimal constant must begin with a nonzero-digit,
'-' is not a nonzero-digit. So '-32768' is not a decimal-constant.

The description of 6.4.4.1 also said:

    An integer constant begins with a digit.
-- 
Xi Ruoyao <ryxi@xxxxxxxxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University




[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