From 7290b16ecde3bb4d31f782c1ba94b82fc2e77353 Mon Sep 17 00:00:00 2001 From: Andrei Pikas Date: Mon, 20 May 2024 02:25:07 +0300 Subject: [PATCH] clang-cl support. --- incbin.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/incbin.h b/incbin.h index 3f662e1..c05cac2 100644 --- a/incbin.h +++ b/incbin.h @@ -70,6 +70,14 @@ #define INCBIN_VA_ARG_COUNTER(_1, _2, _3, N, ...) N #define INCBIN_VA_ARGC(...) INCBIN_VA_ARG_COUNTER(__VA_ARGS__, 3, 2, 1, 0) +#if defined(_MSC_VER) +# if defined(__clang__) +# define INCBIN_CLANGCL 1 +# else +# define INCBIN_MSCL 1 +# endif +#endif + /* Green Hills uses a different directive for including binary data */ #if defined(__ghs__) # if (__ghs_asm == 2) @@ -82,7 +90,7 @@ # define INCBIN_MACRO ".incbin" #endif -#ifndef _MSC_VER +#ifndef INCBIN_MSCL # define INCBIN_ALIGN \ __attribute__((aligned(INCBIN_ALIGNMENT))) #else @@ -174,7 +182,7 @@ # define INCBIN_TYPE(...) #else # define INCBIN_SECTION ".section " INCBIN_OUTPUT_SECTION "\n" -# define INCBIN_GLOBAL(NAME) ".global " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n" +# define INCBIN_GLOBAL(NAME) ".global " INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n" # if defined(__ghs__) # define INCBIN_INT ".word " # else @@ -191,6 +199,8 @@ # elif defined(__MINGW32__) || defined(__MINGW64__) /* Mingw doesn't support this directive either */ # define INCBIN_TYPE(NAME) +# elif defined(INCBIN_CLANGCL) +# define INCBIN_TYPE(NAME) # else /* It's safe to use `@' on other architectures */ # define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", @object\n" @@ -396,7 +406,7 @@ * To externally reference the data included by this in another translation unit * please @see INCBIN_EXTERN. */ -#ifdef _MSC_VER +#ifdef INCBIN_MSCL # define INCBIN(NAME, FILENAME) \ INCBIN_EXTERN(NAME) #else @@ -465,7 +475,7 @@ * To externally reference the data included by this in another translation unit * please @see INCBIN_EXTERN. */ -#if defined(_MSC_VER) +#if defined(INCBIN_MSCL) # define INCTXT(NAME, FILENAME) \ INCBIN_EXTERN(NAME) #else