+-

我在用
DPRINTF(ERROR_LEVEL,"ERROR: error found at file: %s line: %d",__FILE__,__LINE__);
像这样打印
ERROR: error found at file: /home/jeegar/ full path to that file/main.c line: 102
在这里我只想打印
ERROR: error found at file: main.c line: 102
我只想要文件名而不是整个路径
好吧,我用make文件运行这个文件,我正在使用这个机制
PATH_NOW = $(shell pwd)
LIB =$(PATH_NOW)/../lib
什么时候我需要从lib文件夹访问任何文件我只是包括那里
$(LIB)/main.c
最佳答案
更改:
DPRINTF(ERROR_LEVEL,"ERROR: error found at file: %s line: %d",__FILE__,__LINE__);
至:
DPRINTF(ERROR_LEVEL,"ERROR: error found at file: %s line: %d",basename(__FILE__),__LINE__);
点击查看更多相关文章
转载注明原文:c – __FILE__显示带文件名的整个路径 - 乐贴网