In C++20 or higher, the following macro implements the desired behavior.
It's a single line of code and works the same way that __FILE__
does.
#define __FILENAME__ std::string_view(__FILE__).substr(std::string_view(__FILE__).find_last_of("/\\") + 1).data()