[C言語] Cでのポインタの読み方、をcdeclで変換できるよ
http://sakurai.sumomo.ne.jp/page/c_pointer を見てふと思い出したのでメモ。
はてブをみると誰一人このツールのこと書いていないし知らないのかなぁ。
Debian系ならば普通にインストールできます。
# apt-get install cdecl
使い方は"?"で出てきます。あまり使ったことないので良く知りませんが...
cdecl> ? [] means optional; {} means 1 or more; <> means defined elsewhere commands are separated by ';' and newlines command: declareas cast into explain set or set options help, ? quit or exit english: function [( )] returning array [ ] of [{ const | volatile | noalias }] pointer to type: {[ ] [{ }] [ ]} { struct | union | enum } decllist: a comma separated list of , or as name: a C identifier gibberish: a C declaration, like 'int *x', or cast, like '(int *)x' storage-class: extern, static, auto, register C-type: int, char, float, double, or void modifier: short, long, signed, unsigned, const, volatile, or noalias
実際に使ってみます。
基本的な使い方ですが、Cの式からは"explain 式"とタイプします。逆に英文からは"declare 英文"とタイプします。
では、まずは"int *p"とか基本的なのを。
cdecl> explain int *p; declare p as pointer to int cdecl> declare p as pointer to int int *p
すばらしいきちんと動作します。
http://sakurai.sumomo.ne.jp/page/c_pointer の最後の方にある難しい式もこの通り。
cdecl> explain char (*(*fp)(void))(int); declare fp as pointer to function (void) returning pointer to function (int) returning char cdecl> declare fp as pointer to function (void) returning pointer to function (int) returning char char (*(*fp)(void ))(int )
cdeclでググったらWeb版のインターフェースまでありました。わざわざWeb版まで作らなくても、何考えてんだか。
http://cdecl.org/
でも普通typedef使うよね。トリプルポインタまでは使ったことあるけど...。