【C++】nm と c++filt

ライブラリにどんなクラス・関数が含まれているか、nm コマンドで確認できる。

C++の場合、名前が mangling されているので、c++filt を使うと demangle してくれる。

また、nm に -C オプションを付けると demangle してくれる。

$ nm -C libecrobot++.a | grep LightSensor
LightSensor.o:
00000001 T ecrobot::LightSensor::setLamp(bool)
00000001 T ecrobot::LightSensor::LightSensor(ePortS, bool)
00000001 T ecrobot::LightSensor::LightSensor(ePortS, bool)
00000001 T ecrobot::LightSensor::~LightSensor()
00000001 T ecrobot::LightSensor::~LightSensor()
00000001 T ecrobot::LightSensor::~LightSensor()
00000001 T ecrobot::LightSensor::getBrightness() const
00000000 V vtable for ecrobot::LightSensor
RcxLightSensor.o:
00000001 T ecrobot::RcxLightSensor::RcxLightSensor(ePortS)
00000001 T ecrobot::RcxLightSensor::RcxLightSensor(ePortS)
00000001 W ecrobot::RcxLightSensor::~RcxLightSensor()
00000001 W ecrobot::RcxLightSensor::~RcxLightSensor()
00000001 T ecrobot::RcxLightSensor::getBrightness() const
00000000 V vtable for ecrobot::RcxLightSensor