diff options
Diffstat (limited to 'slang.h')
| -rw-r--r-- | slang.h | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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) |
