2023-06-06 update:
windows does not support shell basename. Makefile native support basname like, it’s notdir.
contents
Since gcc-12, gcc native support __FILE_NAME__ macro. ref
Here we provide some methods to make gcc version lower than 12 support __FILE_NAME__:
Makefile:
CXX_FLAGS+=-D__FILE_NAME__=\"$(notdir $<)\"
test: test.c
gcc-7 $(CXX_FLAGS) $<Qt pro:
DEFINES += '__FILE_NAME__=\\\"$(notdir $<)\\\"'Some information of macro is at here.