标签: c++ c
可能重复: C/C++ line number
我想显示触发printf的行号?
看起来像这样:
printf("the line number is: %d",SOME_LIBC_MACRO);
怎么做?
答案 0 :(得分:12)
使用__LINE__宏
__LINE__
printf("the line number is: %d", __LINE__);
其他预定义宏列表可用于GCC和Visual Studio