If you use GNU Make, you can simply pass -D BASE_FILE_NAME = \ "$ *. C \" at the compilation preprocessing stage (if you do them separately or when compiling, if at one stage, which is normal).
It depends on how you determined the file names. Mine comes from a list of simple file names and has a prefix with directories that use functions in the makefile at a later stage.
IE, this works well for me, but your mileage may vary !:-)
A simplified version of my makecode:
CLASSES = main.c init.c PREPROCESSED = $(patsubst %.c,$(PPCDIR)/%.pp.c,$(CLASSES)) $(PREPROCESSED): $(PPCDIR)/%.pp.c: %.c $(ALLH) $(GCC) $(GCCOPTS) -D BASE_FILE_NAME=\"$*\" -E $< > $@
Just use BASE_FILE_NAME in your code as you like :-)
source share