我正在使用
DPRINTF(ERROR_LEVEL,"ERROR: error found at file: %s line: %d",__FILE__,__LINE__);
像这样的it printf
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
我只想要文件名,而不是整个路径。
我正在使用makefile运行此文件,并在其中使用此机制。
PATH_NOW = $(shell pwd)
LIB =$(PATH_NOW)/../lib
每当我需要访问lib文件夹中的任何文件时,我只需在其中包含即可。
$(LIB)/main.c
#include <libgen.h>
以避免警告! - Evert