【ISO/ANSI/JIS】 C言語なら俺に聞け! Part 132 at TECH
[2ch|▼Menu]
471:デフォルトの名無しさん
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

5382日前に更新/146 KB
担当:undef