C语言 打印文件名,行号,函数名

来源:互联网 发布:python erp框架 编辑:程序博客网 时间:2024/04/25 19:10

C 语言中可以使用 __FILE__, __LINE__, __func__ 分别打印文件名,函数名以及行号。

在VIM 中写这些关键字的时候是会变颜色的,可以根据颜色变化检查笔误。

/* This is a non __init function. Force it to be noinline otherwise gcc * makes it inline to init() and it becomes part of init.text section */static noinline int init_post(void){        /* need to finish all async __init code before freeing the memory */        async_synchronize_full();        free_initmem();        mark_rodata_ro();        system_state = SYSTEM_RUNNING;        numa_default_policy();        #qc added test code        printk(KERN_WARNING "+++++ qc, hello linux kernel ! Filename: %s, Line: %s, Func: %s \n",__FILE__, __LINE__,__func__);

原创粉丝点击