[Bug preprocessor/82176] Feature request: replace __FILE__ with file's basename instead its full name

f.hollerer at gmx dot net gcc-bugzilla@gcc.gnu.org
Tue Oct 29 19:21:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

--- Comment #12 from f.hollerer at gmx dot net ---
(In reply to Gregory Fuchedzhy from comment #10)
> (In reply to f.hollerer from comment #8)
> > To my understanding assert() uses __FILE__ and __LINE__. I would like to
> > have a command line option which let __FILE__ expand to the last path
> > component (the filename) instead of an invocation dependent full path of
> > that file.
> 
> If __FILE_NAME__ is implemented would adding -D__FILE__=__FILE_NAME__ solve
> your particular usecase?

Yes, but then I also have to add -Wno-builtin-macro-redefined otherwise the
compiler will issue a warning.

I think best match is the -ffile-prefix-map option joseph@codesourcery.com
pointed me to.


More information about the Gcc-bugs mailing list