November 15, 2004
I am using the __FILE__ macro but am having problems. Sometimes the macro is replaced by the file name, File.cc, both other times it is replaced by the whole path name like /home/dev/test/File.cc. How can I prevent the whole path name from printing?


November 15, 2004
Karyn Chen wrote:
> I am using the __FILE__ macro but am having problems. Sometimes the macro is
> replaced by the file name, File.cc, both other times it is replaced by the whole
> path name like /home/dev/test/File.cc. How can I prevent the whole path name
> from printing?

It depends on the file name passed to the compiler. If the command line contains "File.cc", then __FILE__ will be "File.cc". OTOH, if you pass a path on the command line, the path version is what you get.

Search google for a function called "basename".