#ifndef PLUGIN_OFFSETOF_H #define PLUGIN_OFFSETOF_H #include /* defines offsetof to be __builtin_offsetof */ __attribute__((const, noinline)) static size_t __spslr_offsetof(const char *t, const char *m, size_t v) { /* never executed; replaced by plugin */ (void)t; (void)m; (void)v; return v; } /* Replace __builtin_offsetof with encoding of type and member that survives C frontend */ #undef __builtin_offsetof #define __builtin_offsetof(T,M) \ ((size_t (*)(const char*, const char*, size_t))__spslr_offsetof)((#T), (#M), (((size_t)&((T*)0)->M))) #endif