From e39893e8eb1a9411fca4e5f885456a27a770d3a2 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 10 Mar 2023 12:24:51 -0500 Subject: Add struct version to DownstreamCompiler::CompileOptions interface (#2692) * #include an absolute path didn't work - because paths were taken to always be relative. * Add versioning to CompileOptions for DownstreamCompiler so we can add new options without breaking binary interface. * Use builtin offset of directly. --- slang.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'slang.h') diff --git a/slang.h b/slang.h index d281cea85..ac097fbde 100644 --- a/slang.h +++ b/slang.h @@ -238,11 +238,14 @@ convention for interface methods. # define SLANG_BREAKPOINT(id) __builtin_trap(); # define SLANG_ALIGN_OF(T) __alignof__(T) -// Use this macro instead of offsetof, because gcc produces warning if offsetof is used on a -// non POD type, even though it produces the correct result -# define SLANG_OFFSET_OF(T, ELEMENT) (size_t(&((T*)1)->ELEMENT) - 1) +// Use the builtin directly so we don't need to have an include of stddef.h +# define SLANG_OFFSET_OF(T, ELEMENT) __builtin_offsetof(T, ELEMENT) #endif // SLANG_GCC_FAMILY +#ifndef SLANG_OFFSET_OF +# define SLANG_OFFSET_OF(T, ELEMENT) (size_t(&((T*)1)->ELEMENT) - 1) +#endif + // Microsoft VC specific #if SLANG_MICROSOFT_FAMILY # define SLANG_NO_INLINE __declspec(noinline) -- cgit v1.2.3