鳳鳴は祖父の俳号

日記 メモ そんなの

GNU APL1.0 MacOSX10.8での作業メモ 3

 追記:修正にミスあり。よくわかってないからこんなことに……

 Xcodeを最新の5.0にしてCommandLineToolsもアップデートした後(gccLLVMになる)、ComplexCell.ccの該当箇所を以下の様に修正。昨晩はこの()=を抜かしてしまった。
395 if (Cell::is_near_zero(z.real(), 2e-15)) z.real()=0.0 ;
396 if (Cell::is_near_zero(z.imag(), 2e-15)) z.imag()=0.0 ;

 該当箇所を通過し、lapack.ccでエラーとなった。(これは次回)

 修正前はこのような記述:

395 if (Cell::is_near_zero(z.real(), 2e-15)) z.real(0.0);
396 if (Cell::is_near_zero(z.imag(), 2e-15)) z.imag(0.0);

元に戻してmakeすると

ComplexCell.cc:395:53: error: no matching member function for call to 'real'
if (Cell::is_near_zero(z.real(), 2e-15)) z.real(0.0) ;
~~^~~~
/usr/include/c++/4.2.1/complex:1198:20: note: candidate function not viable: requires 0 arguments, but 1 was provided
complex::real()
^
/usr/include/c++/4.2.1/complex:1202:20: note: candidate function not viable: requires 0 arguments, but 1 was provided
complex::real() const
^
ComplexCell.cc:396:53: error: no matching member function for call to 'imag'
if (Cell::is_near_zero(z.imag(), 2e-15)) z.imag(0.0) ;
~~^~~~

 となった。

 現在、homebrewでgcc4.9をインストール中なのだがまわりっぱなし。結局使わないで済むみたいなんだけど……

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー


 前回のこの部分:
ComplexCell.cc: In member function ‘virtual void ComplexCell::bif_power(Cell*, const Cell*) const’:
ComplexCell.cc:395: error: no matching function for call to ‘std::complex::real(double)’
/usr/include/c++/4.2.1/complex:1199: note: candidates are: double& std::complex::real()
/usr/include/c++/4.2.1/complex:1203: note: const double& std::complex::real() const
ComplexCell.cc:396: error: no matching function for call to ‘std::complex::imag(double)’
/usr/include/c++/4.2.1/complex:1207: note: candidates are: double& std::complex::imag()
/usr/include/c++/4.2.1/complex:1211: note: const double& std::complex::imag() const

ですけど、

と教えていただいたのでComplexCell.ccの以下の箇所を修正。(よくわかっていない)
395 if (Cell::is_near_zero(z.real(), 2e-15)) z.real 0.0 ;
396 if (Cell::is_near_zero(z.imag(), 2e-15)) z.imag 0.0 ;

すると、エラーは以下のように変わった。
ComplexCell.cc:395: error: expected `;' before numeric constant
ComplexCell.cc:395: error: statement cannot resolve address of overloaded function

 セミコロン周り?セミコロンを削ってみたり、if文なので{}でくくってみたりしたけど変わらず。(よくわかっていない)
g++のバージョンを確認せよとのことだったので

$ g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 すると

real - C++ Reference
Page Redirection - GNU Project - Free Software Foundation (FSF)

 4.2.1だとダメ?再確認するとXcode5.0のCommandLineToolsはアップデートがあった。適用すると:
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix

 make cleanで掃除したあともう一回./configureしmake。エラーメッセージの表示がカラフルになりwarningがたくさんでるようになった。これはあとで。エラー箇所は変わらず。

ComplexCell.cc:395:57: error: expected ';' after expression
if (Cell::is_near_zero(z.real(), 2e-15)) z.real 0.0 ;
^
;
ComplexCell.cc:395:51: error: reference to non-static member function must be called
if (Cell::is_near_zero(z.real(), 2e-15)) z.real 0.0 ;
^~~~~~
ComplexCell.cc:396:57: error: expected ';' after expression
if (Cell::is_near_zero(z.imag(), 2e-15)) z.imag 0.0 ;
^
;
ComplexCell.cc:396:51: error: reference to non-static member function must be called
if (Cell::is_near_zero(z.imag(), 2e-15)) z.imag 0.0 ;
^~~~~~

 このあと、コンパイルオプション std=c++11を入れてみては?ということで
./configure CFLAGS="std=c++11"
とやってMakefileを作るとこからやり直し。configure中に

configure: WARNING: fcntl.h: present but cannot be compiled
configure: WARNING: fcntl.h: check for missing prerequisite headers?
configure: WARNING: fcntl.h: see the Autoconf documentation
configure: WARNING: fcntl.h: section "Present But Cannot Be Compiled"
configure: WARNING: fcntl.h: proceeding with the compiler's result
configure: WARNING: ## ------------------------------ ##
configure: WARNING: ## Report this to bug-apl@gnu.org ##
configure: WARNING: ## ------------------------------ ##

と出たが取り敢えず無視してmakeしてみたら

../Backtrace.cc:223:46: error: cannot initialize a parameter of type 'size_t *' (aka 'unsigned long *') with an rvalue of type 'unsigned int *'
__cxxabiv1::__cxa_demangle(fun, obuf, &obuflen, &status);
^~~~~~~~
/usr/include/cxxabi.h:141:20: note: passing argument to parameter 'length' here
size_t* length,
^

 ありゃー。仕様の違いか?

CPPFLAGS="-std=c++11"が良いよということでやってみたら:
$ ./configure CPPFLAGS="-std=c++11"
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking for gcc... gcc
checking whether we are using the GNU C compiler... no
checking whether gcc accepts -g... no
checking for gcc option to accept ISO C89... unsupported
checking dependency style of gcc... gcc3
checking for ranlib... ranlib
checking how to run the C preprocessor... /lib/cpp
configure: error: in `/Users/takesita/apl-1.0':
configure: error: C preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.

 今日はここまで。ねこきっく先生(@finalfusion)ありがとうございました。

メモ:zreal 0.0やzimage 0.0の行をコメントアウトすると次はlapack関連のエラーが待っている。MacOSXの開発環境は標準でlapackがあるというのだが
macOS - Apple Developer
メモ2:ComplexCell.ccだけ-std=c++11つけてダマせるか。それはいいのか?
メモ3:別マシンで別環境用意するか?
Mac OS X に GCC 4.8 をインストール - mattintosh note
MacOSXの Homebrewで最新の GCC 4.7.0 をインストール - しがないプログラマ の日記