一个用于内核,一个用于非内核
/*
7 * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
8 * header files exported to user space
9 */
10
11 typedef __signed__ char __s8;
12 typedef unsigned char __u8;
13
14 typedef __signed__ short __s16;
15 typedef unsigned short __u16;
16
17 typedef __signed__ int __s32;
18 typedef unsigned int __u32;
19
20 #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
21 typedef __signed__ long long __s64;
22 typedef unsigned long long __u64;
23 #endif
24
25 /*
26 * These aren't exported outside the kernel to avoid name space clashes
27 */
28 #ifdef __KERNEL__
29
30 typedef signed char s8;
31 typedef unsigned char u8;
32
33 typedef signed short s16;
34 typedef unsigned short u16;
35
36 typedef signed int s32;
37 typedef unsigned int u32;
38
39 typedef signed long long s64;
40 typedef unsigned long long u64;
41
42 #define BITS_PER_LONG 32
43
44 typedef u32 dma_addr_t;
45
46 #endif /* __KERNEL__ */
int 和long int 语法上 有区别
正规写法:
long int -- 32 位有符号整型
short int -- 16 位有符号整型
编译器 允许的 简略写法:
long -- 32 位有符号整型
short -- 16 位有符号整型
如果写成 int, 那么是不确定 写法,长度由编译器自行规定
TC int -- 16 位有符号整型, 即 short int
MS VC++ int -- 32 位有符号整型, 即 long int
输入语句,long int 用 %ld ,short int 用 %d
编译器 也许通融 %d 既可读 long 也可读 short。
阅读(1662) | 评论(0) | 转发(0) |