From a88e1d1c598e641eecd5d43730211d91c82787c6 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Wed, 23 Apr 2014 12:19:59 +0200 Subject: lavu: add CHK_OFFS as AV_CHECK_OFFSET to check struct member offsets --- libavutil/internal.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libavutil/internal.h') diff --git a/libavutil/internal.h b/libavutil/internal.h index ecd535b808..210c52437e 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -84,6 +84,13 @@ // to be forced to tokenize __VA_ARGS__ #define E1(x) x +/* Check if the hard coded offset of a struct member still matches reality. + * Induce a compilation failure if not. + */ +#define AV_CHECK_OFFSET(s, m, o) struct check_##o { \ + int x_##o[offsetof(s, m) == o? 1: -1]; \ + } + #define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \ uint8_t la_##v[sizeof(t s o) + (a)]; \ t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a) -- cgit v1.2.3