Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1079859
  • 博文数量: 165
  • 博客积分: 3900
  • 博客等级: 中校
  • 技术积分: 1887
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-06 15:15
文章分类

全部博文(165)

文章存档

2020年(3)

2019年(8)

2017年(2)

2016年(8)

2015年(14)

2013年(15)

2012年(32)

2011年(11)

2010年(14)

2009年(7)

2008年(20)

2007年(31)

分类: C/C++

2012-07-17 23:29:09

一直以为宏定义是C语言里面最近简单的东东, 今天看了putty的代码,终于枉然大悟,原来宏定义还有我不能理解的 !!!!!!!!


openssh代码里面有几个奇怪的宏:
#define crBegin(v)    { int *crLine = &v; switch(v) { case 0:;

#define crFinish(z)    } *crLine = 0; return (z); }

#define crReturn(z)    \
    do {\
        *crLine =__LINE__; return (z); case __LINE__:;\
    } while (0)

google了一下,才知道这几个宏是实现coroutine(协程)的。
有关协程的资料可以通过下面的链接详细了解:
~sgtatham/coroutines.html

这个宏如果在msvc中编译需要单独设置设置宏所在的文件,假设文件为ssh.c:
* - right-click ssh.c in the FileView
* - click Settings
* - select the C/C++ tab and the General category
* - under `Debug info:', select anything _other_ than `Program
*    Database for Edit and Continue'.
阅读(1750) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~