__typeof__ (const int)
Liu Hao
lh_mouse@126.com
Thu Feb 16 14:34:00 GMT 2017
On 2017/2/16 21:39, Jonathan Wakely wrote:
>> On a private target (using newlib-stdint.h), sizeof(__typeof__ (-32768))
>> returns 4 but sizeof(__typeof__ (-32767)) returns 2...
>
> This has nothing to do with __typeof__ only to do with the rules of C
> that determine the type of an integer constant, see
> http://en.cppreference.com/w/c/language/integer_constant#The_type_of_the_integer_constant
>
> Presumably your private port has a 16-bit int, so -32768 doesn't fit
> in int and has a 32-bit type instead. If that's not the case then you
> have a bug in the port and it's selecting the wrong type for the
> integer constant -32767.
>
It is 32768 that does not fit in `int`. There is no negative integer
constant. -32768 is a unary minus operator followed by an integer
constant 32768, which has type `long` if it does not fit in `int`.
--
Best regards,
LH_Mouse
More information about the Gcc-help
mailing list