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<
You can assign __FILE__
to a string, and then call _splitpath() to rip the pieces out of it. This might be a Windows/MSVC-only solution, honestly I don't know.
I know you were looking for a compile-time solution and this is a run-time solution, but I figured since you were using the filename to do (presumably run-time) error logging, this could be a simple straightforward way to get you what you need.