EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Warning when initializing a long variable
From: Bob Soliday <[email protected]>
To: "Schoeneburg, Bernd" <[email protected]>, Tech-talk <[email protected]>
Date: Tue, 21 Apr 2009 15:29:06 -0500
Bob Soliday wrote:
Schoeneburg, Bernd wrote:
Hi all,
when I try to initalize a long variable with the most negative value of -2147483648 which should be 0xFFFFFFFF, then I get a compiler warning. The compiler is gcc version 3.4.5 running on solaris.

long test_var = -2147483648L;
....
../devPbdp.c:80: warning: decimal constant is so large that it is unsigned

-2147483647 is accepted. This problem exists only with long. char and short can be initialized to the most negative values without any problem.

Any idea? Thank you....

- Bernd


> /usr/include/sys/types.h defines LONG_MIN as -2147483647L-1L
>
> I don't know why they defined it this way but I assume there
> is a reason.
>
> --Bob
>

I have figured out the reason this works. The language syntax definition doesn't define negative number literals, rather the negative numbers are generated by the unary - operator. What this means is that it is not reading -2147483648L the way you think it is. Instead it is reading it as -(2147483648L). Since 2147483647L is equal to LONG_MAX it does not know what to do with a number even bigger.


References:
Warning when initializing a long variable Schoeneburg, Bernd

Navigate by Date:
Prev: Warning when initializing a long variable Schoeneburg, Bernd
Next: Priorities of epicsThreads on Linux jun-ichi.odagiri
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Warning when initializing a long variable Schoeneburg, Bernd
Next: Priorities of epicsThreads on Linux jun-ichi.odagiri
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 31 Jan 2014 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·