C程序:定义宏打印某位域共有多少位
#include <stdio.h>
#define bits(p, d) { \
int _tmp=p->d, _bits=0; \
for (p->d=1; p->d; p->d<<=1) \
_bits++; \
p->d=_tmp; \
printf("%s->%s has %d bits", #p, #d, _bits); \
}
typedef struct _s{
int a:4;
} S;
int main()
{
S tmp, *s = &tmp;
bits(s,a);
}
/* 输出: s->a has 4 bits */
相关文档:
C没有类
这让人很疲惫
对象的说法很时髦
不就是继承封装组合人人会
右走是C++,这个大众都熟悉它
左走就是objective-c,躲在僻静僻静的麦金塔
本是同根生的C
如何高举面向对象的大旗
求同存异标新立异且听一一细分清
对象的C
是不同的C
类的处理与众不同重点要区分
不重复是我的口头禅
任何时候我只说一次告诉 ......
摘要:
在学习linux内核代码及一些开源软件的源码(如:DirectFB),经常可以看到有关
__attribute__的相关使用。本文结合自己的学习经历,较为详细的介绍了__attribute__
相关语法及其使用。
---------------------------------------------------------
声明:
此文为原创,欢迎转载,转载请保留如下信息
& ......
/*
思路:递归算法
前0..cur-1位置上已经排好,当前cur位置取一个和前面都不一样的,然后递归处理后面的。
*/
/* 输出1,2,3,..,n的排列数 */
#include <stdio.h>
#include <assert.h>
#include <malloc.h>
void p(int n)
{
extern void _p(int n, int cur, int *a);
int *a;
a = ......