__FILE_NAME__ not defined in gcc < 12 #12477
Unanswered
aeschbacher
asked this question in
Q&A
Replies: 1 comment 8 replies
-
I don't think it's necessarily meson's place to provide such a macro. This could be readily resolved in your application without meson contributing at all, e.g. /* project/config.h */
#pragma once
#if !defined(__FILE_NAME__)
static inline const char *basename(const char *path)
{ /* return the pointer after the last / in the string */ }
// NOTE: Technically UB to define this name, but do what you need to
#define __FILE_NAME__ basename(__FILE__)
#endif |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There are situations (when saving space is critical) where preferring the
__FILE_NAME__
predefined macro over__FILE__
can make sense. Unfortunately the__FILE_NAME__
macro is not available before gcc 12.With GNU Make, it would be possible to
#define
it using-D__FILE_NAME__
and some$<
magic. I failed to find the right way of doing this with Meson build. The obvious answer would be for sure to wait until it's possible to update to gcc 12 for the project (but upgrading a cross toolchain is a bigger change).I'm wondering if it's possible in Meson with a reasonable effort ?
Beta Was this translation helpful? Give feedback.
All reactions