Skip to content

Commit e1fc7a3

Browse files
Patch support for clang till cpp20.
Signed-off-by: Toria <ninetailedtori@uwu.gal>
1 parent eeca662 commit e1fc7a3

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/include/millennium/logger.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,19 @@ void CleanupLoggers();
262262
#define PRETTY_FUNCTION __PRETTY_FUNCTION__
263263
#endif
264264

265+
#if defined(__clang__)
266+
#ifndef LOG_ERROR
267+
#define LOG_ERROR(...) logger.private_error_do_not_use(fmt, __sanitize_nt(__FILE__).data(), __LINE__, PRETTY_FUNCTION REST(__VA_ARGS__))
268+
#define FIRST(...) FIRST_HELPER(__VA_ARGS__, throwaway)
269+
#define FIRST_HELPER(first, ...) first
270+
#define REST(...) REST_HELPER(NUM(__VA_ARGS__), __VA_ARGS__)
271+
#define REST_HELPER(qty, ...) REST_HELPER2(qty, __VA_ARGS__)
272+
#define REST_HELPER2(qty, ...) REST_HELPER_##qty(__VA_ARGS__)
273+
#define REST_HELPER_ONE(first)
274+
#define REST_HELPER_TWOORMORE(first, ...) , __VA_ARGS__
275+
#define NUM(...) SELECT_10TH(__VA_ARGS__, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, ONE, throwaway)
276+
#define SELECT_10TH(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, ...) a10
277+
#endif
278+
#else
265279
#define LOG_ERROR(fmt, ...) logger.private_error_do_not_use(fmt, __sanitize_nt(__FILE__).data(), __LINE__, PRETTY_FUNCTION, ##__VA_ARGS__)
266280
#define GET_GITHUB_URL_FROM_HERE() fmt::format("{}/blob/{}{}#L{}", MILLENNIUM_REPOSITORY, GIT_COMMIT_HASH, __get_source_loc(__sanitize_nt(__FILE__).data()).data(), __LINE__)

0 commit comments

Comments
 (0)