Compiling gnu findutils on Solaris 10 (SunOS 5.10) - HUGE_VAL problem

Computing 2010. 6. 4. 17:32

I have encountered an error compiling findutils-4.4.0 on Solaris 10 (SunOS 5.10).

gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -I../gnulib/lib -I../lib -I../gnulib/lib -I../intl -DLOCALEDIR=\"/usr/local/share/locale\"  -I/usr/local/include  -g -O2 -MT pred.o -MD -MP -MF .deps/pred.Tpo -c -o pred.o pred.c
pred.c: In function `file_sparseness':
pred.c:661: error: invalid operands to binary *
make[3]: *** [pred.o] Error 1
make[3]: Leaving directory `/home1/shawn/sources/findutils-4.4.0/find'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home1/shawn/sources/findutils-4.4.0/find'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home1/shawn/sources/findutils-4.4.0'
make: *** [all] Error 2

The problem was that HUGE_VAL was not a number but a pointer. The definition of HUGE_VAL can be found in math_c99.h.

I was curious if the same error occurs when I used Solaris native cc, and I ran a test. It was OK. It was also OK with gcc. But if I specified -std=gnu99 in gcc commandline, it reproduced the same problem.

I started thinking, is.... HUGE_VAL a function pointer? And I modified find/pred.c as :

shawn.r1:~/sources/findutils-4.4.0/find$ diff pred.c.orig pred.c
661c661
<       return p->st_blocks < 0 ? -HUGE_VAL : HUGE_VAL;
---
>       return p->st_blocks < 0 ? (-1 * HUGE_VAL()) : HUGE_VAL();

Gottya. It went well. HUGE_VAL IS a function pointer.


Resolve :

treat HUGE_VAL as a function pointer by specifying "()" behind it.

: