[Cython] All DEF constants are now unsigned?
Stefan Behnel
stefan_ml at behnel.de
Sun Sep 6 14:30:37 CEST 2015
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.
https://github.com/cython/cython/commit/37f6b07978d3ca1b41aae4d1dd747ee63e3b9265
Thanks!
Stefan
More information about the cython-devel
mailing list