|
|
@ -27,23 +27,24 @@
|
|
|
|
// paths from being encoded into the binary at all. Assumes / is the
|
|
|
|
// paths from being encoded into the binary at all. Assumes / is the
|
|
|
|
// path separator.
|
|
|
|
// path separator.
|
|
|
|
namespace _ {
|
|
|
|
namespace _ {
|
|
|
|
constexpr const char* static_basename_impl(const char* b, const char* t) {
|
|
|
|
constexpr const char* static_basename_impl(const char* b, const char* t) {
|
|
|
|
return *t == '\0' ? b : static_basename_impl(*t == '/' ? t+1 : b, t+1);
|
|
|
|
return *t == '\0' ? b : static_basename_impl(*t == '/' ? t+1 : b, t+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
constexpr const char* static_basename(const char* p) {
|
|
|
|
constexpr const char* static_basename(const char* p) {
|
|
|
|
return static_basename_impl(p, p);
|
|
|
|
return static_basename_impl(p, p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
constexpr int static_strlen(const char* s) {
|
|
|
|
constexpr int static_strlen(const char* s) {
|
|
|
|
return *s == '\0' ? 0 : static_strlen(s + 1) + 1;
|
|
|
|
return *s == '\0' ? 0 : static_strlen(s + 1) + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template<int N, int...I>
|
|
|
|
template<int N, int...I>
|
|
|
|
static constexpr decltype(auto) static_alloc_str_impl(const char* str, std::integer_sequence<int, I...>) {
|
|
|
|
static constexpr decltype(auto) static_alloc_str_impl(const char* str, std::integer_sequence<int, I...>) {
|
|
|
|
return (struct {char buf[N+1];}) {str[I]..., 0};
|
|
|
|
typedef struct {char buf[N+1];} static_null_terminated;
|
|
|
|
}
|
|
|
|
return (static_null_terminated) {str[I]..., '\0'};
|
|
|
|
template<int N>
|
|
|
|
}
|
|
|
|
static constexpr decltype(auto) static_alloc_str(const char* str) {
|
|
|
|
template<int N>
|
|
|
|
return static_alloc_str_impl<N>(str, std::make_integer_sequence<int, N>());
|
|
|
|
static constexpr decltype(auto) static_alloc_str(const char* str) {
|
|
|
|
}
|
|
|
|
return static_alloc_str_impl<N>(str, std::make_integer_sequence<int, N>());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#define __FILE_BASE__ (_::static_alloc_str<_::static_strlen(_::static_basename(__FILE__))>(_::static_basename(__FILE__)).buf)
|
|
|
|
#define __FILE_BASE__ (_::static_alloc_str<_::static_strlen(_::static_basename(__FILE__))>(_::static_basename(__FILE__)).buf)
|
|
|
|
|
|
|
|
|
|
|
|