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

Computing 2010.06.04 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
<       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.

tags : , ,
Trackback 0 : Comments 5
  1. BlogIcon whiterock 2010.06.07 10:23 신고 Modify/Delete Reply

    다 방면으로 오덕의 후광이..ㅋ.ㅋ.ㅋ.

  2. 준영 2010.07.08 17:30 신고 Modify/Delete Reply

    휴지_발 이라서 생기는 오류인듯.

Write a comment

티스토리 툴바