这个链接是:GCC的相对于标准C的51项扩充(编译器扩展语法标准) 看来是不行啊~ 在 2010年11月1日 下午6:02,Pengfei Li <lpfwd007@xxxxxxxxx>写道: > 这个是GCC的一个扩展 > 看这里 > http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html > > 不知道在标准C里面能不能用。 > > 在 2010年11月1日 下午5:59,jun fang <apifan@xxxxxxxxx>写道: > > 顶 >> >> 2010/11/1 seaturn <haiyue.wang@xxxxxxxxx> >> >> 参考: >>> #define container_of(ptr, type, member) ({ \ >>> const typeof( ((type *)0)->member ) *__mptr = (ptr); \ >>> (type *)( (char *)__mptr - offsetof(type,member) );}) >>> >>> do while 不行! >>> >>> >>> >>> >>> 在 2010年11月1日 下午5:46,Wugang Qiu <qiuwugang@xxxxxxxxx>写道: >>> >>>> 怎么用宏定义 返回 一个返回值(宏包含多条语句)? 以前看到过这样的代码,不过想不起来了,好像就是利用{}的最后 一个表达式的值 就是 >>>> {}定义体 的值这个特点; >>>> >>>> >>>> #define xxx(var) do{ \ >>>> int a; \ >>>> a=func(var); \ >>>> }while(0) >>>> >>> >>> >>> >>> -- >>> Best Regards, >>> Haiyue >>> >>> >> > -- Best Regards, Haiyue