c和指针读书笔记——宏用于注释代码的小技巧

 1 #include <stdio.h>
2 #include <stdlib.h>
3 /*
4 int a=0; /*此行注释开头的注释符被当做普通字符,此行注释结尾的注释符被看做是注释的结束*/
5
6 */ /* 此行开始的表示注释结束的符号由于无法匹配报错。 */
7
8 int main()
9 {
10 printf("he\n");
11 return EXIT_SUCCESS;
12 }

再看下面的代码:

#include <stdio.h>
#include <stdlib.h>
#if 0
int a=0;
   这里可以写被注释的代码
#endif

int main()
{
printf("he\n");
return EXIT_SUCCESS;
}

最近注意到vs中有一个按照特定模式生成代码的选项,具体如下:

  1: #ifdef _DEBUG
  2: 
  3: //这里写在debug模式下要写的代码
  4: //这里的代码不会在release模式下算到源程序里
  5: 
  6: #endif
posted @ 2011-11-29 18:36  martin@dlut  阅读(474)  评论(0编辑  收藏  举报