首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从源代码编译Ruby1.8.7时出错: math.c:37: error:标记前缺少二元运算符"(“

从源代码编译Ruby1.8.7时出错: math.c:37: error:标记前缺少二元运算符"(“
EN

Stack Overflow用户
提问于 2011-03-04 20:50:18
回答 1查看 4.2K关注 0票数 7

这真的很奇怪:

代码语言:javascript
复制
: 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不能被编译:

代码语言:javascript
复制
: 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没有明显的问题:

代码语言:javascript
复制
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;
    }
}

让我们来看看预处理器生成了什么:

代码语言:javascript
复制
: 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 "("

好了,看起来没问题,所以让我们编译一下,看看问题在哪里:

代码语言:javascript
复制
: 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了。但我还是想知道世界上发生了什么。

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-04 21:34:52

它应该显示为#elif defined(XXX)

票数 15
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5193935

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档