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

2021-05-31 Thread clyon at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

Christophe Lyon  changed:

   What|Removed |Added

 CC||clyon at gcc dot gnu.org

--- Comment #13 from Christophe Lyon  ---
FWIW, I've recently fixed PR 42579.

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

2019-10-29 Thread f.hollerer at gmx dot net
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 jos...@codesourcery.com
pointed me to.

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

2019-10-29 Thread f.hollerer at gmx dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

--- Comment #11 from f.hollerer at gmx dot net ---
(In reply to jos...@codesourcery.com from comment #9)
> On Tue, 29 Oct 2019, f.hollerer at gmx dot net wrote:
> 
> > This would:
> > 
> > - shorten the output of assert()
> > - minimize the image size due to shorter strings
> > - make the build reproduceable as the output does not depend on the current
> > working directory.
> 
> Note that we have the -ffile-prefix-map / -fmacro-prefix-map / 
> -fdebug-prefix-map options you can use to specify a mapping from the 
> actual directory names used in the build to the names you want to appear 
> in the output.

Thank you for pointing me to this options. I have to get a more recent compiler
to try them, but according the documentation they should solve my problem.

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

2019-10-29 Thread fuchedzhy at google dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

--- Comment #10 from Gregory Fuchedzhy  ---
(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?

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

2019-10-29 Thread joseph at codesourcery dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

--- Comment #9 from joseph at codesourcery dot com  ---
On Tue, 29 Oct 2019, f.hollerer at gmx dot net wrote:

> This would:
> 
> - shorten the output of assert()
> - minimize the image size due to shorter strings
> - make the build reproduceable as the output does not depend on the current
> working directory.

Note that we have the -ffile-prefix-map / -fmacro-prefix-map / 
-fdebug-prefix-map options you can use to specify a mapping from the 
actual directory names used in the build to the names you want to appear 
in the output.

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

2019-10-29 Thread f.hollerer at gmx dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

--- Comment #8 from f.hollerer at gmx dot net ---
I have to correct me. The __FILE_NAME__ macro goes in the direction I would
like to have. But this does not solve the problem with assert().

My preferred solution is to have the expansion of the __FILE__ macro controlled
by a command line options.

As explained in my original post I use third party code which is augmented with
asserts(). I don't want to touch this code.

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.

This would:

- shorten the output of assert()
- minimize the image size due to shorter strings
- make the build reproduceable as the output does not depend on the current
working directory.

To sum up. This is what the feature request is about:

https://www.iar.com/support/tech-notes/general/avoiding-full-paths-in-the-output-file/

Please provide a '--no_path_in_file_macros' as provided by the IAC compiler.

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

2019-10-29 Thread f.hollerer at gmx dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

--- Comment #7 from f.hollerer at gmx dot net ---
Yes, the __FILE_NAME__ macro provided by Clang is exactly the feature I am
asking for:

__FILE_NAME__
Clang-specific extension that functions similar to __FILE__ but only
renders the last path component (the filename) instead of an invocation
dependent full path to that file.

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

2019-10-26 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

--- Comment #6 from Eric Gallager  ---
(In reply to Gregory Fuchedzhy from comment #5)
> (In reply to Eric Gallager from comment #3)
> > *** Bug 91998 has been marked as a duplicate of this bug. ***
> 
> Not exactly a duplicate, but related.
> Clang implemented an additional __FILE_NAME__ macro.
> 
> See:
> https://reviews.llvm.org/D61756
> https://reviews.llvm.org/D17741

oh ok, I guess that's actually a dup of bug 42579 instead, then...

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

2019-10-04 Thread fuchedzhy at google dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

--- Comment #5 from Gregory Fuchedzhy  ---
(In reply to Eric Gallager from comment #3)
> *** Bug 91998 has been marked as a duplicate of this bug. ***

Not exactly a duplicate, but related.
Clang implemented an additional __FILE_NAME__ macro.

See:
https://reviews.llvm.org/D61756
https://reviews.llvm.org/D17741

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

2019-10-04 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

Eric Gallager  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-10-04
 Ever confirmed|0   |1

--- Comment #4 from Eric Gallager  ---
Taking dup as confirmation

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

2019-10-04 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

Eric Gallager  changed:

   What|Removed |Added

 CC||fuchedzhy at google dot com

--- Comment #3 from Eric Gallager  ---
*** Bug 91998 has been marked as a duplicate of this bug. ***

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

2017-09-11 Thread f.hollerer at gmx dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

--- Comment #2 from f.hollerer at gmx dot net ---
> See PR 42579 which has a patch to add __FILE_BASENAME__ for this purpose.

Unfortunately this does not solve the problem when __FILE__ is used indirectly
via the assert() macro shipped with the compiler toolchain.

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

2017-09-11 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82176

Jonathan Wakely  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=42579
   Severity|normal  |enhancement

--- Comment #1 from Jonathan Wakely  ---
See PR 42579 which has a patch to add __FILE_BASENAME__ for this purpose.