Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C __文件u uu用文件名显示整个路径_C_Linux_Makefile - Fatal编程技术网

C __文件u uu用文件名显示整个路径

C __文件u uu用文件名显示整个路径,c,linux,makefile,C,Linux,Makefile,我正在使用 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 我只想要文件名而不是整个路径 我

我正在使用

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 file运行这个文件,在其中我使用了这个机制

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__);