If I use the __FILE__ macro it expands to the name of the current file as a string constant.
What I want to do is define a macro to be the bare file name.
For instance, I might have a file FRED.c in the directory C:\projects. If I have
#define FILENAME __FILE__
I get FILENAME defined as the string constant "FRED.c" (I think some compilers return the path information as well, mine doesn't (at least by default)).
What I need is to be able to set FILENAME to just FRED (without the extension and without the quotes).
Any ideas on how this might be done? It needs to be done with the preprocessor, so writing a function isn't an option. Nor is writing a separate program to read this file and modify the code before compiling it.
What I want to do is define a macro to be the bare file name.
For instance, I might have a file FRED.c in the directory C:\projects. If I have
#define FILENAME __FILE__
I get FILENAME defined as the string constant "FRED.c" (I think some compilers return the path information as well, mine doesn't (at least by default)).
What I need is to be able to set FILENAME to just FRED (without the extension and without the quotes).
Any ideas on how this might be done? It needs to be done with the preprocessor, so writing a function isn't an option. Nor is writing a separate program to read this file and modify the code before compiling it.