I\'m using GCC; __FILE__ returns the current source file\'s entire path and name: /path/to/file.cpp
. Is there a way to get just the file\'s name file.cpp<
I don't know of a direct way. You could use:
#line 1 "filename.c"
at the top of the source file to set the value of __FILE__
, but I'm not sure that that's much better than hard coding it. or just using a #define to create your own macro.
Another option might be to pass the name from your Makefile using -D and $(shell basename $<)
Edit: If you use a #define or the -D option, you should create your own new name and not try to redefine __FILE__
.