2011-06-02から1日間の記事一覧

コマンドラインのプリプロセッサー定義で文字列を渡す

$ cc -o hello hello.c -DHELLO="\"hello, world!\"" $ ./hello hello, world!などと、コンパイルオプションで渡した文字列をソースコードで使うにはどうしたらいいか?解答編: #define quote(x) q(x) #define q(x) #x #include <stdio.h> int main() { puts(quote(H</stdio.h>…