[Cython] All DEF constants are now unsigned?

Robert Bradshaw robertwb at gmail.com
Tue Sep 8 00:53:06 CEST 2015


On Sun, Sep 6, 2015 at 5:30 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Jeroen Demeyer schrieb am 06.09.2015 um 10:54:
>> On 2015-09-05 17:09, Stefan Behnel wrote:
>>> It now appends the 'U' suffix only to literals that are used in an unsigned
>>> context (e.g. assignment to unsigned variable), and additionally appends
>>> L/LL suffixes for integers that might exceed the int/long limits.
>>
>> Why not just keep it simple, append no suffixes and let the C/C++ compiler
>> deal with it? No heuristics needed.
>>
>> More concretely, I would handle this as follows:
>> * do not use any L or U suffix
>> * write all DEF constants as hexadecimal in the source code
>>
>> This way, the C/C++ compiler will determine the integral type.
>
> I previously tried that with decimal literals and got warnings in gcc.
> Hadn't tried hex literals.
>
>
>> It will use
>> the first type in the following list which can represent the number:
>> - int
>> - unsigned int
>> - long
>> - unsigned long
>> - long long
>> - unsigned long long
>>
>> The reason for the *hexadecimal* constants is that the unsigned types are
>> not tried for decimal constants.
>
> That's interesting to know (you were quoting 6.4.4 of the C standard
> apparently). C - what a language full of wonders.

Wow, I didn't know that either... thanks for the pointer.


More information about the cython-devel mailing list