2011-03-04 10 views
6

Esto es realmente extraño:Error al compilar Rubí 1.8.7 de la fuente: math.c: 37: error: falta operador binario antes de token "("

suficiente
: [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 

Claro, math.c no puede ser compilado :

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

No hay nada malo con, obviamente, 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; 
    } 
} 

Veamos lo que está generando el pre-procesador:

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

bien, se ve bien, así que vamos a compilar y ver dónde está el problema:

: [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 

Ahora que he compilado manualmente math.c en math.o, puedo construir rubí. Pero aún me gustaría saber qué está pasando en el mundo.

¿Alguna idea?

Respuesta

13

Debe leer "#elif defined (XXX)"

+0

¡Gracias! Guau, ¿entonces este era un error en Ruby? Me pregunto por qué su prueba de construcción no lo atrapó? ¿Algunas CFLAGS extrañas? Funciona de fábrica en ruby-1.8.7-p334. –

+0

Supongo que su entorno de construcción tomó la rama #if, en ese caso cualquier cosa después del #elif simplemente se ignoró. – Lindydancer

Cuestiones relacionadas