Stringification in C

来源:互联网 发布:fc2视频域名 编辑:程序博客网 时间:2024/05/17 07:38
     #define xstr(s) str(s)     #define str(s) #s     #define foo 4     str (foo)          ==> "foo"     xstr (foo)          ==> xstr (4)          ==> str (4)          ==> "4"# work as Stringification symbol in above sample which could be very useful in some cases.
     #define WARN_IF(EXP) \     do { if (EXP) \             fprintf (stderr, "Warning: " #EXP "\n"); } \     while (0)     WARN_IF (x == 0);          ==> do { if (x == 0)                fprintf (stderr, "Warning: " "x == 0" "\n"); } while (0);

0 0
原创粉丝点击