Hello, world!

2008-05-26

#, ##

Cのpreprocessorの話題

#

文字列展開する。
ex. helloと出力
#define abc(efg)  name[] = #efg
abc(hello);
printf("%s\n");

##

前後の文字を結合して展開
ex. 使う値を変えてみる
#define MAX_ia64_LIMITS 512
#define MAX_x86_LIMITS  256
#define LIMITS(arch)  MAX_##arch##_LIMITS
printf("%d\n",LIMITS(ia64));
printf("%d\n",LIMITS(x86));