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