pjsjasen

    1. #define st(x)      do { x } while (__LINE__ == -1) 讲解: __LINE__ 是个宏,它代表当前代码在源文件的行号,它是大于0的,所以__LINE__ == -1 等同于0,化简为: #define st(x)      do { x } while (0) Example: #define a(x) if(x) { printf("%s\n", "OK"); } int i = 1; if(0)     a(i); else     printf("%s\n", "KO"); Will expand to something equivalent to: if(0) {     if(x)     {         printf("%s\n", "OK");     }     else printf("%s\n", "KO"); } However if you define a(x) as: #define a(x) st(if(x) { printf("%s\n", "OK"); }) it will work, expanding to: if(0) {     do     {         if(x)         {             printf("%s\n", "OK");         }     }     while(0); } else printf("%s\n", "KO");
    2. 学习了

最近访客

< 1/1 >

统计信息

已有3人来访过

  • 芯积分:--
  • 好友:--
  • 主题:--
  • 回复:2

留言

你需要登录后才可以留言 登录 | 注册


现在还没有留言