【ISO/ANSI/JIS】 C言語なら俺に聞け! Part 132at TECH
【ISO/ANSI/JIS】 C言語なら俺に聞け! Part 132 - 暇つぶし2ch471:デフォルトの名無しさん
07/11/28 21:03:42
>>468
>同時に実装しなければならないならプリプロセッサでの切り分けはできないと思うが
できますよ、というか出来てます。#undef まで書けば同じファイルにすら実装できます。
下の 2 ファイルを用意して test.cpp をプリプロセッサにかけてみてください。

/* ./template/test.cpp */
#ifdef TYPE_A
#define type_ type_ar
#define name_ func_a
#endif

#ifdef TYPE_B
#define type_ type_b
#define name_ func_b
#endif

type_ *name_( type_ *param );

#undef type_
#undef name_

/* ./test.cpp */
#define TYPE_A
#include "./template/test.cpp"
#undef TYPE_A

#define TYPE_B
#include "./template/test.cpp"
#undef TYPE_B



次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch