nmatrixをインストールする

nmatrixをFreeBSDにインストールしようとしてつまづいた。

FreeBSDはclangを使っている、というのが問題である。nmatrixのreadmeによればexperimentalらしい。

まず、extconf.rbでRbConfig::CONFIG['CXX']を参照しているが、これはc++になっているはずで、実態はclang++である。しかし、extconf.rbではCXXがclang++でなければgccであると仮定している。この判定方法は改善の余地がありそうだ。

とりあえず、*まずは*自分さえよければいいので

elsif CONFIG['CXX'] == 'c++'
  $CPP_STANDARD = 'c++11'

と付け加えてしのぐ。

そうすると、なんだかうまくいくような感じにみえるが....

$ make                                    [~/github/nmatrix/ext/nmatrix:master]
compiling nmatrix.cpp
In file included from nmatrix.cpp:44:
In file included from ./data/data.h:45:
./data/ruby_object.h:116:10: error: conversion function cannot be redeclared
  inline operator uint64_t() const { RETURN_OBJ2NUM(NUM2ULONG)      }
         ^
./data/ruby_object.h:113:10: note: previous declaration is here
  inline operator VALUE() const { return rval; }
         ^
In file included from nmatrix.cpp:283:
./ruby_nmatrix.c:1102:11: warning: unused variable 'elem' [-Wunused-variable]
    void* elem = s->elements;
          ^
./ruby_nmatrix.c:2692:38: warning: comparison of unsigned expression >= 0 is
      always true [-Wtautological-compare]
      if (rb_ary_entry(begin_end, 0) >= 0)
          ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~
./ruby_nmatrix.c:2696:38: warning: comparison of unsigned expression >= 0 is
      always true [-Wtautological-compare]
      if (rb_ary_entry(begin_end, 1) >= 0)
          ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~
3 warnings and 1 error generated.
*** Error code 1

Stop.
make: stopped in /usr/home/murashin/github/nmatrix/ext/nmatrix
zsh: exit 1     make

というわけで、エラーが出てコンパイルできない。

C++はよくしらないが、operator uint64_t()で型キャストしたときの振舞を定義、というか、オーバーロードしたというべきか、しているようだ。

もしかして、VALUEっていう型とuint64_tって同じ型なのでは? と思って調べてみた。VALUEがuintptr_tという型なのは分かった。

uintptr_tは__uintptr_tであり、__uint64_tはuint64_tで、__uint64_tは__uintptr_tだ!
あーっ。。。。。

こういうときどうするんでしょうか?

(追記) VALUEの型キャストを定義しているところをコメントアウトしたらコンパイル通りました。なんだよ要らないのかよ!