开发者

__FILE__ shows whole path with filename

i am using

DPRINTF(ERROR_LEVEL,"ERROR: error found at file: %s line: %d",__FILE__,__LINE__);

it printf like this

ERROR: error found at file: /home/jeegar/ full path to that file/main.c line: 102

here i just want to print only

ERROR: error found at file: main.c line: 102

i just want file name not w开发者_运维知识库hole path

well i m running this file with make file and in which i am using this mechanism

PATH_NOW              = $(shell pwd)
LIB                   =$(PATH_NOW)/../lib

when ever i need to access any file from lib folder i just include there

$(LIB)/main.c


Change:

DPRINTF(ERROR_LEVEL,"ERROR: error found at file: %s line: %d",__FILE__,__LINE__);

to:

DPRINTF(ERROR_LEVEL,"ERROR: error found at file: %s line: %d",basename(__FILE__),__LINE__);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜