GNU C ANSI C 一些区别
1 可变数据结构
struct var_data
{
int len;
char data[0];
};
遍历len后数据
for(i = 0; i < s.len; i++)
{
printf("%02x",s.data[i]);
}
2 case 范围区间 【x,y】
3 语句表达
#define min_t (type, x, y) \
({ type __x = (x); type __y = (y); __x < __y ? __x: __y;})
int ia, ib, mini;
float fa, fb, minf;
mini = min_t ( int, ia, ib);
minf = min_f (float, fa, fb);
标准c:
#define min (x, y) ((x) < (y) ? (x) : (y))
代码min ( ++ia, ++ib) 被展开为 ((++ia) < (++ib) ? (++ia):(++ib)) ia,ib 被加了两次。
4 typeof
#define min(x, y) ( {\
const typeof(x) __x = (x); \
const typeof(y) __y = (y);\
(void) (&__x ==&__y); \
__x <_ _y ? __x : __y ;})
5 pr_debug 可防止在参数选项不代表任何参数的时候 不输出,。
6 可指定范围初始化数组 unsigned char data [MAX] = { [0 ... MAX - 2] = 0};
结构体成员初始化结构体:
struct file_operations ext2_file_operations =
{
llseek:generic_file_llseek,
read: generic_file_read,
}
同样,标准c:
struct file_operations ext2_file_opreations =
{
.llseek = generic_file_llseek,
.read = generic_file_read,
}
.....
相关文档:
/* find files from wildcards, for MicroSoft C v4.0 */
/* ------------------------------------------------------------ */
/* copyright 1986: */
/* Nourse Gregg & Browne, Inc. */
/* 1 Horizon Road. #612 ......
1、C/C++程序员请注意,不能在case语句不为空时“向下执行”。
2、值类型和引用类型之间的区别:C#的基本类型(int,char等)都是值类型,是在栈中创建的。而对象是引用类型,创建于堆中,需要使用关键字new。
3、在C#中通过实例访问静态方法或成员变量是不合法的,会生成编译器错误。但是我们可以 ......
windows7 + ubuntu9.10双启动,这个有太多的帖子了,不过这次的情况比较复杂.
先装的WIN7,后装UBUNTU,没有任何问题.GRUB双启动.
后来因为一个情况,要装XP,把WIN7做了 ghost.装完XP,GRUB当然没有了,于是用ubuntu启动盘修复.
虽然启动菜单出来了,但只能进行ubuntu,进入windows的时候就提示error:cannot get C/H/S value ......
C1X是C语言即C99标准之后将要推出的最新标准,了解到得原文如下:
C1X is the unofficial name of the planned new standard for the C programming language. It is intended to replace the existing C standard. This predecessor is informally known as C99. The standard is not yet fin ......