Linux_2.6.32内核文档翻译计划,1. linux内核printk格式

1. linux 内核 printk 格式

原英文文档: linux-2.6.32/Documentation/printk-formats.txt

 

如果变量类型是 ,        使用 prink 的格式说明符 :

-----------------------------------------------------------------------------------------------------

int                                %d 或者 %x( 译者注: %d 是十进制, %x 是十六进制 )

unsigned int                  %u 或者 %x

long                             %ld 或者 %lx

unsigned long                %lu 或者 %lx

long long                      %lld 或者 %llx

unsigned long long         %llu 或者 %llx

size_t                           %zu 或者 %zx

ssize_t                          %zd 或者 %zx

 

原始指针值必须用 %p 输出。

u64 必须用 %llu 或者 %llx 输出, (unsigned long logn):

printk("%llu", (unsigned long long)u64_var);

s64 必须用 %lld 或者 %llx 输出, (long long):

       printk("%lld", (long long)s64_var);

如果 ( 变量类型 )<type> 的长度依赖一个配置选项 ( 例如: sector_t, blkcnt_t, phys_addr_t, resource_size_t) 或者 依赖相关的体系结构(例如: tcflag_t ),使用一个可能最大类型的格式说明符,并且显示转换它。例如:

printk("test: sector number/total blocks: %llu/%llu/n",

  (unsigned long long)sector, (unsigned long long)blockcount);

提醒: sizeof()( 译者注: sizeof() 是 C 操作符 ) 的结果是 size_t 类型。

感谢您的合作和注意。

Randy Dunlap <[email protected] > 著 .

 

Author: Wenxy, (Chinese name: Xiaoyong Wen, English name:Jack Wen).

Email: [email protected]

Blog: http://blog.csdn.net/wenxy1

Copyright: Wenxy

Licence: GPL v2 or latest.                                                               

Caution: Only non-commercial use, reproduce, please indicate the source.

警告:些文档仅供非商业用途,转载请注明出处!

 

你可能感兴趣的:(c,linux,文档,linux内核)