微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从源代码编译Ruby 1.8.7时出错:math.c:37:错误:令牌之前缺少二进制运算符“(”

这真的很奇怪:
: 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

果然,math.c无法编译:

: 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 "("

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;
    }
}

让我们看看预处理器产生的内容

: 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 "("

好的,看起来没问题,所以让我们编译它,看看问题出在哪里:

: 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

现在我已经将math.c手动编译成math.o,我可以构建ruby.但我仍然想知道世界上到底发生了什么.

有任何想法吗?

解决方法

它应该是“#elif defined(XXX)”

原文地址:https://www.jb51.cc/ruby/267636.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐