« 参考 | メイン | ドラゴンフェスタ »

2004年10月09日

[技術] C言語

/* Access method description structure. */
typedef struct __db {
DBTYPE type; /* Underlying db type. */
int (*close) __P((struct __db *));
int (*del) __P((const struct __db *, const DBT *, u_int));
int (*get) __P((const struct __db *, const DBT *, DBT *, u_int));
int (*put) __P((const struct __db *, DBT *, const DBT *, u_int));
int (*seq) __P((const struct __db *, DBT *, DBT *, u_int));
int (*sync) __P((const struct __db *, u_int));
void *internal; /* Access method private. */
int (*fd) __P((const struct __db *));
} DB;

の__P()の意味がわからんかった。

答えは以下だそうだ。

-----
古いコンパイラでもコンパイルできるように
プロトタイプ宣言を使い分ける時の方法だね。

前もって
#define __P(x) x
と宣言すれば、
int main (int, char *[]);
と展開され、

#define __P(x)
と宣言すれば、
int main ();
と展開される。
-------------------

ありがとうございます。

投稿者 nekobara : 2004年10月09日 23:02


コメント