6
这实在是奇怪:错误从源代码编译的Ruby 1.8.7时:math.c:37:错误:缺少前令牌二进制运算符 “(”
足够: [email protected]; wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.tar.bz2
: [email protected]; tar xvjf ruby-1.8.7.tar.bz2
: [email protected]; cd ruby-1.8.7/
: [email protected]; CFLAGS='-O0 -g -Wall' ./configure --disable-pthread
: [email protected]; 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
当然,math.c不能编译:
: [email protected]; 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 "("
没有什么明显的错误与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;
}
}
让我们来看看预处理器产生:
: [email protected]; 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,看起来好了,让我们编译一下,看看问题出在哪里:
: [email protected]; gcc -O0 -g -Wall -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c /tmp/math.c
: [email protected]; echo $?
0
: [email protected]; ls -l math.o
-rw-r--r-- 1 josh josh 20904 2011-03-04 13:47 math.o
现在,我已经手动编译math.c到math.o,我可以建立红宝石。但我仍然想知道世界正在发生什么。
任何想法?
谢谢! 哇,这是Ruby中的一个错误?想知道为什么他们的构建测试没有抓住它?一些奇怪的CFLAGS? ruby-1.8.7-p334开箱即用。 – 2011-03-04 13:53:58
猜测他们的构建环境采用了#if分支,在这种情况下,#elif之后的任何内容都被忽略。 – Lindydancer 2011-03-04 13:57:54