main 関数で exit(0) と return 0 の違い

つまりローカル変数のデストラクタが呼ばれるかどうか、ということ。

exitの時

#include <iostream>

using namespace std;

class Foo {
public:
  Foo() {}
  ~Foo() { cout << "Destructor was called." << endl; }
};

int main() {
  Foo foo;
  exit(0);
}

結果

$ ./a.out
$

returnの時

#include <iostream>

using namespace std;

class Foo {
public:
  Foo() {}
  ~Foo() { cout << "Destructor was called." << endl; }
};

int main() {
  Foo foo;
  return 0;
}

結果

$ ./a.out
Destructor was called.
$

plenv で perl の切り替えがうまく行かないメモ

ずっと Perl のバージョンを切り替えるツールとして perlbrew を使っていたけど、気がむいたので GitHub - tokuhirom/plenv: Perl binary manager を使ってみようとして失敗した時のメモ

現象

$ plenv global perl-5.16 とすると
5.16 is not installed on plenv. at ~/.plenv/bin/plenv と言われてしまう

原因

インストールする時に
$ plenv install perl-5.16.3 --as perl-5.16
とインストール名を perl-5.16 て名前に変更していた

原因2

plenv は ~/.plenv/versions/ の配下に Perl のバージョンに合わせて 5.16.3 とか 5.14.4 とかバージョン番号だけのディレクトリを作成して管理するのがデフォルト

'--as' オプションを付けると別のディレクトリ名にできるけど、perl-5.16 とかするとうまく動かない

plenv は global オプションを受け取った時に「気を利かせて」perl-5.16.3 から 'perl-' 部分を除いて 5.16.3 だと思ってスイッチしてくれる。普通に使う上ではそれでよい。plenv global 5.16.3 でも plenv global perl-5.16.3 でも受け入れてくれる。
plenv install する時に 5.16.3 ではなくて perl-5.16.3 と指定してもうまく行ったのも、同様な「配慮」によるもの。

しかし perlbrew 脳の私はインストール名として perl-5.16 を指定したため、すべてを台無しにしていた。

解決策

'--as' オプションを付ける時は perl- はじまりの名前を付けない

Ubuntu で pogoplug を使う時のメモ

クラウドサービスじゃない、機器の方のPogoplugに普通にUSBのハードディスクを繋いで使う時のメモ

公式サイトでは 32bit 版の pogoplugfs バイナリしか用意されれいないので、64bitでUbuntuをインストールしていると結構困る。
以下手順

1.クロスコンパイルの環境を用意する

・具体的には gcc-multilib , g++-multilib というのをインストールしておく

2.fuse のソースを取得して手元でコンパイルする

・この辺を参照64 bit - Is it possible to have 32 bit libraries installed on a 64 bit system? - Ask Ubuntu

sudo apt-get install ia32-libs libc6-i386
sudo apt-get build-dep fuse
apt-get source fuse
cd fuse-2.8.4
CFLAGS=-m32 ./configure --host=i386-linux-gnu
make -j 50
sudo install -m644 lib/.libs/libfuse.so.2.8.4 /usr/local/lib/
cd /usr/local/lib
sudo ln -s libfuse.so.2.8.4 libfuse.so.2
ldconfig

3. 適当にmountpointを作って、そこにマウントする

mkdir ~/pogoplug
pogoplugfs --mountpoint ~/pogoplug --user --password --fuseopts allow_other > ~/log/pogoplugfs.log 2>&1 &