This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: compiler warning about literal
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Luchezar Belev <lukcho at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Mon, 17 Nov 2014 16:46:08 +0000
- Subject: Re: compiler warning about literal
- Authentication-results: sourceware.org; auth=none
- References: <CAJtzQrzpZeQ2uHvuaG4HJWdjaW-=FuEdchr1rcf3N3K-hqPxKw at mail dot gmail dot com>
On 17 November 2014 16:22, Luchezar Belev <lukcho@gmail.com> wrote:
> hi,
>
> when i try to compile this c code:
> long long t = 2684354560;
> gcc (version 4.8.2) says: " ...warning: this decimal constant is
> unsigned only in ISO C90 [enabled by default]"
>
> i added the option -std=C90 but i still get the same warning.
> Is there a way one can get rid of this warning (other than adding the
> "u" suffix to the literal, which i can't do for complicated reasons
> that are beyond this question)
The right thing to do is use an ll suffix.
long long t = 2684354560ll;
> I wonder why does gcc give such warning at all given that in either
> standard the literal decimal number "2684354560" is valid:
> a) in ISO C90 it will be interpreted as unsigned long and
> b) in ISO C99 it will be interpreted as signed long long
The fact it means different things in different cases is why you get a warning.