On 10/5/12 11:27 AM, Greg Wooledge wrote:
> On Fri, Oct 05, 2012 at 05:20:23PM +0200, Andreas Schwab wrote:
>> Greg Wooledge <[email protected]> writes:
>>
>>> Line 1209 says:
>>> # if (ULLONG_MAX != LLONG_MAX)
>>>
>>> LLONG_MAX expands to:
>>> ((long long int) (~ (long long int) 0 - ((long long int) ((! ((long long
>>> int) 0 < (long long int) -1)) ? ~ (long long int) 0 << (sizeof (long long
>>> int) * 8 - 1) : (long long int) 0))))
>>
>> That's not a valid expansion for this macro, it cannot contain casts or
>> the sizeof operator.
>
> Then there's a serious problem somewhere, because that's what gcc -E is
> giving me. Copying the top part of getconf.c and then jumping straight
> to the heart of the matter:
> # 1 "getconf.h" 1
> # 31 "foo.c" 2
>
>
> extern int errno;
>
>
> ((long long int) (~ (long long int) 0 - ((long long int) ((! ((long long int)
> 0 < (long long int) -1)) ? ~ (long long int) 0 << (sizeof (long long int) * 8
> - 1) : (long long int) 0))))
That looks like it comes from include/typemax.h. I derived the macros
there from an earlier version of the god-awful mess that appears in
gnulib's strtol.c, ammong other places. It hasn't changed in a long time.
Why would you say there's a restriction against using casts or sizeof in
a macro like this? Even the newer versions of that code in gnulib use
them.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/