#if CompilerIsMsvc //////////////////////////////// //~ Msvc incbin types Struct(IncbinRcSearchParams) { /* In */ String name_lower; /* Out */ b32 found; String data; }; typedef i32 IncbinStatus; enum { IncbinStatus_Unsearched, IncbinStatus_Searching, IncbinStatus_Searched }; Struct(IncbinRcResource) { Atomic32 state; String rc_name; String data; }; //////////////////////////////// //~ Msvc incbin operations b32 IncbinEnumerateResourceNamesFunc(void *module, const wchar_t *type, const wchar_t *wstr_entry_name, i64 udata); String StringFromIncbinRcResource(IncbinRcResource *inc); /* NOTE: Msvc doesn't have an Inline assembler that can include binary data. * So instead these macros will trigger a lookup into the embedded RC file for * entries matched by name (this requires the build system to generate and link * RC file). */ #define IncbinInclude(var, _rc_name) static IncbinRcResource _incbin_ ## var = { .rc_name = LIT_NOCAST((_rc_name)) } #define IncbinGet(var) StringFromIncbinRcResource(&_incbin_ ## var) String StringFromIncbinRcResource(struct IncbinRcResource *inc); #else /* CompilerIsMsvc */ //////////////////////////////// //~ Clang incbin operations #if PlatformIsWindows # define IncbinSection ".rdata, \"dr\"" #elif PlatformIsMac # define IncbinSection "__TEXT,__const" #else # define IncbinSection ".rodata" #endif /* Includes raw binary data into the executable. */ /* https://gist.github.com/mmozeiko/ed9655cf50341553d282 */ #define IncbinInclude(var, filename) \ __asm__(".section " IncbinSection "\n" \ ".global _incbin_" Stringize(var) "_start\n" \ ".balign 16\n" \ "_incbin_" Stringize(var) "_start:\n" \ ".incbin \"" filename "\"\n" \ \ ".global _incbin_" Stringize(var) "_end\n" \ ".balign 1\n" \ "_incbin_" Stringize(var) "_end:\n" \ ); \ extern __attribute((aligned(16))) const char _incbin_ ## var ## _start[]; \ extern const char _incbin_ ## var ## _end[] /* Retrieve a string from included data using the variable supplied to IncbinInclude */ #define IncbinGet(var) STRING_FROM_POINTERS(_incbin_ ## var ## _start, _incbin_ ## var ## _end) #endif /* CompilerIsClang */