This is really odd:
: josh@josh; wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.tar.bz2
: josh@josh; tar xvjf ruby-1.8.7.tar.bz2
: josh@josh; cd ruby-1.8.7/
: josh@josh; CFLAGS='-O0 -g -Wall' ./configure --disable-pthread
: josh@josh; make
gcc -O0 -g -Wall -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c array.c
[...]
gcc -O0 -g -Wall -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c math.c
math.c: In function ‘domain_check’:
math.c:37: error: missing binary operator before token "("
make: *** [math.o] Error 1
Sure enough, math.c cannot be compiled:
: josh@josh; gcc -O0 -g -Wall -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c math.c
math.c: In function ‘domain_check’:
math.c:37: error: missing binary operator before token "("
There's nothing obviously wrong with math.c:
static void
domain_check(x, msg)
double x;
char *msg;
{
while(1) {
if (errno) {
rb_sys_fail(msg);
}
if (isnan(x)) {
#if defined(EDOM)
errno = EDOM;
#elif define(ERANGE) # <== this is line 37
errno = ERANGE;
#endif
continue;
}
break;
}
}
Let's see what the pre-processor is generating:
: josh@josh; gcc -E -O0 -g -Wall -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c math.c >/tmp/math.c
math.c:37: error: missing binary operator before token "("
OK, looks alright, so let's compile it and see where the problem is:
: josh@josh; gcc -O0 -g -Wall -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c /tmp/math.c
: josh@josh; echo $?
0
: josh@josh; ls -l math.o
-rw-r--r-- 1 josh josh 20904 2011-03开发者_运维百科-04 13:47 math.o
Now that I've manually compiled math.c into math.o, I can build ruby. But I'd still like to know what in the world is going on.
Any ideas?
It should read #elif defined(XXX)
.
精彩评论