宏"__FUNCTION__" 和" __LINE__ "

简介: 宏"__FUNCTION__" 和" __LINE__ "

__FUNCTION__,当前函数名,类型char const*

__LINE__, 在单前文件中的行,类型int


用于日志中,方便查错。例如:


void

func()

{

 

printf

(

"source line %d, in function %s"

,__LINE__,__FUNCTION__);

}


 

int

main()

{

 

func();

 

return

0;

}


相关文章
|
安全 编译器 程序员
15 C++ - 内联函数(inline function)
15 C++ - 内联函数(inline function)
125 0
|
5月前
|
存储 API Windows
MASM32连接程序时error A2006: undefined symbol : u
MASM32连接程序时error A2006: undefined symbol : u
|
编译器 C语言
__FILE__, __LINE__ __FUNCTION__
__FILE__, __LINE__ __FUNCTION__
用#define宏实现Add函数
用#define宏实现Add函数
116 0
error: possibly undefined macro: LT_SYS_SYMBOL_USCORE please use m4_pattern_allow
error: possibly undefined macro: LT_SYS_SYMBOL_USCORE please use m4_pattern_allow
162 0
error: implicit declaration of function ‘read‘ [-Werror,-Wimplicit-function-declaration]
error: implicit declaration of function ‘read‘ [-Werror,-Wimplicit-function-declaration]
282 0
|
C++
warning C4996 sprintf This function or variable may be unsafe
warning C4996 sprintf This function or variable may be unsafe
95 0
|
缓存
Cannot resolve symbol 'R' 解决的几种方法
Cannot resolve symbol 'R' 解决的几种方法
673 0
Cannot resolve symbol 'R' 解决的几种方法
|
测试技术 C语言
Function(函数)
Function(函数)
113 0
|
编译器 C++
尽量以const、enum、inline替换#define
尽量以const、enum、inline替换#define
199 0
尽量以const、enum、inline替换#define