#include と #define

諸事情で、ある一定の法則性を持っているファイルを沢山 #include とかしたくなったのです。 手書きするとこんな感じ。

#include "../lib_a/lib_a.h"
#pragma comment(lib, "../lib_a/release/lib_a.lib")

#include "../lib_b/lib_b.h"
#pragma comment(lib, "../lib_b/release/lib_b.lib")

#include "../lib_c/lib_c.h"
#pragma comment(lib, "../lib_c/release/lib_c.lib")

#include "../lib_d/lib_d.h"
#pragma comment(lib, "../lib_d/release/lib_d.lib")

 :
 :

とまぁ、手書きするとミス率が上がりますし(実際書いてて間違えた)、第一正直タルイので(ぉ、展開用のヘッダファイルを作ってゴニョろうかと思ったわけです。

#define LIB_NAME "lib_a"
#include "includer.h"
#undef LIB_NAME

#define LIB_NAME "lib_b"
#include "includer.h"
#undef LIB_NAME

#define LIB_NAME "lib_c"
#include "includer.h"
#undef LIB_NAME

#define LIB_NAME "lib_d"
#include "includer.h"
#undef LIB_NAME
// includer.h
#include "../" LIB_NAME "/" LIB_NAME ".h"
#pragma comment(lib, "../" LIBNAME "/release/" LIB_NAME ".lib")

C言語では、文字列を並べると無条件に結合されますからそれを利用したわけです。 よーしこれでOKだー!


…とか思ったら、#include でコケル。orz
見事に文字列が結合されていない模様…。うむむむ…。

プリプロセスの処理順序を変えてあげれば、上手く通るかなぁ…とか思い色々抵抗してみて

#define DEFINE_CAT(x, y) x y

とか

#define DEFINE_CAT_(x, y) x y
#define DEFINE_CAT(x, y) DEFINE_CAT_(x, y)

とか定義して、使ってみましたが結果変わらず。orz


手書きするしかないのかぁ…
それとも、他に上手い方法は何かあるものだろうか…。