宏"__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;

}


相关文章
|
7月前
|
编译器 C语言
__FILE__, __LINE__ __FUNCTION__
__FILE__, __LINE__ __FUNCTION__
|
10月前
|
Linux
error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
77 0
|
11月前
uniapp请求接口返回:ER_SP_UNDECLARED_VAR: Undeclared variable: NaN 已解决
uniapp请求接口返回:ER_SP_UNDECLARED_VAR: Undeclared variable: NaN 已解决
80 1
|
11月前
用#define宏实现Add函数
用#define宏实现Add函数
63 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
110 0
error: implicit declaration of function ‘RAND_egd’ [-Werror=implicit-function-declaration]
error: implicit declaration of function ‘RAND_egd’ [-Werror=implicit-function-declaration]
95 0
error: implicit declaration of function ‘read‘ [-Werror,-Wimplicit-function-declaration]
error: implicit declaration of function ‘read‘ [-Werror,-Wimplicit-function-declaration]
176 0
|
C++
warning C4996 sprintf This function or variable may be unsafe
warning C4996 sprintf This function or variable may be unsafe
64 0
VC下__func__未定义,改用__FUNCTION__
VC下__func__未定义,改用__FUNCTION__
67 0
|
测试技术 C语言
Function(函数)
Function(函数)
77 0