C11 provides static assertions via _Static_assert and provides static_assert as a convenience define for this in assert.h. MSVC 19.27 declares support for C11, but does not support _Static_assert, but somehow supports static_assert. That's therefore what we use.
But apparently there are some old GCC toolchains where _Static_assert is supported, but assert.h does not provide the fallback define. Some fate boxes are affected by this [1]. This commit therefore checks whether static_assert works with assert.h included; if not, it errors out. Users like the above can still add -Dstatic_assert=_Static_assert to cflags as a workaround. [1]: https://fate.ffmpeg.org/report.cgi?time=20240321123620&slot=sh4-debian-qemu-gcc-4.7 Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- This is what a test without fallback looks like. Posted to gather opinions on what people prefer. configure | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/configure b/configure index 6d7b33b0ff..c2d2c70c20 100755 --- a/configure +++ b/configure @@ -5589,6 +5589,19 @@ check_cxxflags_cc -std=$stdcxx ctype.h "__cplusplus >= 201103L" || check_cflags_cc -std=$stdc ctype.h "__STDC_VERSION__ >= 201112L" || { check_cflags_cc -std=c11 ctype.h "__STDC_VERSION__ >= 201112L" && stdc="c11" || die "Compiler lacks C11 support"; } +test_cc <<EOF || die "Compiler lacks support for C11 static_assert" +#include <assert.h> +#include <stddef.h> +struct Foo { + int a; + void *ptr; +} obj; +static_assert(offsetof(struct Foo, a) == 0, + "First element of struct does not have offset 0"); +static_assert(offsetof(struct Foo, ptr) >= offsetof(struct Foo, a) + sizeof(obj.a), + "elements not properly ordered in struct"); +EOF + check_cppflags -D_FILE_OFFSET_BITS=64 check_cppflags -D_LARGEFILE_SOURCE -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".