Project

General

Profile

Actions

Bug #2118

closed

SUN の cc (SunStudio11 C 5.8 コンパイラ) で dir.c のコンパイルに失敗する

Added by ngoto (Naohisa Goto) over 14 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-09-18) [sparc-solaris2.10]
Backport:

Description

=begin
Solaris10 上の Sun Studio 11 C 5.8 コンパイラにて trunk r25000 の
コンパイルに失敗します。

$ ./configure --prefix=/XXXXX/testruby/sparc/trunk-25000_64cc
MAKE=/usr/local/64/bin/make
CC=/opt/SUNWspro/bin/cc
CXX=/opt/SUNWspro/bin/CC
CFLAGS="-xarch=v9 -xtarget=native64 -I/usr/local/64/include"
LDSHARED="/opt/SUNWspro/bin/cc -G"
LDFLAGS="-xarch=v9 -xtarget=native64 -L/usr/local/64/lib -R/usr/local/64/lib"

$ /usr/local/64/bin/make
(中略)
/opt/SUNWspro/bin/cc -xarch=v9 -xtarget=native64 -I/usr/local/64/include -I. -I.ext/include/sparc-solaris2.10 -I./include -I. -DRUBY_EXPORT -o dir.o -c dir.c
"./include/ruby/ruby.h", line 958: warning: implicit function declaration: rb_type
"dir.c", line 394: operands have incompatible types:
void ":" unsigned long
"dir.c", line 394: operands have incompatible types:
volatile unsigned long ":" void
"dir.c", line 1632: operands have incompatible types:
void ":" unsigned long
"dir.c", line 1632: operands have incompatible types:
volatile unsigned long ":" void
"dir.c", line 1662: operands have incompatible types:
void ":" unsigned long
"dir.c", line 1662: operands have incompatible types:
volatile unsigned long ":" void
cc: acomp failed for dir.c
make: *** [dir.o] Error 2

Warningはいったんは無視して、エラーに着目すると、

"dir.c", line 394: operands have incompatible types:
void ":" unsigned long
が発生している行の内容は、
GlobPathValue(dirname, FALSE);
です。これはマクロで、
#define GlobPathValue(str, safe)
/* can contain null bytes as separators */
(!RB_TYPE_P(str, T_STRING) ?
FilePathValue(str) :
(safe) ? rb_check_safe_obj(str) : (str))
のように3項演算子を使用していて、
この中で rb_check_safe_obj(str) が void を返す関数のため、
3項演算子内で型に互換性がないというエラーを出しているようです。

以下のように「,」を使って値 0 を返すようにしたらコンパイルは通りました。
rb_check_safe_obj(str) を囲む()は不要かもしれませんが念のため入れました。

--- dir.c (revision 25000)
+++ dir.c (working copy)
@@ -343,7 +343,7 @@
/* can contain null bytes as separators */
(!RB_TYPE_P(str, T_STRING) ?
FilePathValue(str) : \

  • (safe) ? rb_check_safe_obj(str) : (str))
    
  • (safe) ? ((rb_check_safe_obj(str)),0) : (str))
    

static VALUE
dir_s_alloc(VALUE klass)

"./include/ruby/ruby.h", line 958: warning: implicit function declaration: rb_type
は今のところ gcc 以外の場合にのみ出る warning のようで、
rb_type のプロトタイプ宣言を TYPE() が使われる前に入れれば消えました。

--- include/ruby/ruby.h (revision 25000)
+++ include/ruby/ruby.h (working copy)
@@ -952,6 +952,7 @@
#ifdef GNUC

define NUM2CHR(x) ({VALUE num2chr_x = (x); NUM2CHR_internal(num2chr_x);})

#else
+static inline int rb_type(VALUE);
static inline char
NUM2CHR(VALUE x)
{

=end

Actions #1

Updated by nobu (Nobuyoshi Nakada) over 14 years ago

  • Status changed from Open to Closed

=begin
Applied in changeset r25002.
=end

Actions

Also available in: Atom PDF

Like0
Like0