从源代码编译Ruby 1.8.7时出错:math.c:37:错误:在标记之前缺少二元运算符“(” [英] Error when compiling Ruby 1.8.7 from source: math.c:37: error: missing binary operator before token "("

查看:329
本文介绍了从源代码编译Ruby 1.8.7时出错:math.c:37:错误:在标记之前缺少二元运算符“(”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这真的很奇怪:

 :josh @ josh; wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.ta​​r.bz2 
:josh @ josh; tar xvjf ruby​​-1.8.7.ta​​r.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。 -一世。 -c array.c
[...]
gcc -O0 -g -Wall -DRUBY_EXPORT -D_GNU_SOURCE = 1 -I。 -一世。 -c math.c
math.c:在函数'domain_check'中:
math.c:37:错误:在令牌之前缺少二元运算符(
make:*** [math .o]错误1

果然,math.c无法编译:

 :josh @ josh; gcc -O0 -g -Wall -DRUBY_EXPORT -D_GNU_SOURCE = 1 -I。-I。-c math.c 
math.c:函数'domain_check':
math.c:37:错误:在令牌之前缺少二元运算符(

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)#< ==这是第37行
errno = ERANGE;
#endif
continue;
}
break;
}
}

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

 :josh @ josh; gcc -E -O0 -g -Wall -DRUBY_EXPORT -D_GNU_SOURCE = 1 -I。 -一世。 -c math.c> /tmp/math.c 
math.c:37:error:missing token 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
code>

现在我已经手动将math.c编译为math.o,我可以构建ruby,但是我仍然想知道这个世界正在发生什么。



有什么想法?

解决方案

<它应该是#elif defined(XXX)


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)"

这篇关于从源代码编译Ruby 1.8.7时出错:math.c:37:错误:在标记之前缺少二元运算符“(”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆