From ff4c0ca0191342cc83362ca7ead93c7552daccad Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Mon, 3 Feb 2025 17:13:22 +0000
Subject: [PATCH] testautomation: Verify that SIZEOF_VOIDP has been set
correctly
As discussed on #229, if we're going to try to detect this from compiler
predefined macros like `__LP64__`, we should verify that we've done
it correctly; otherwise, we could end up incorrectly assuming 32-bit
pointers on a 64-bit Unix platform that doesn't define `__LP64__`
(if such a thing exists).
This static assertion succeeds on all Debian architectures where a build
has been attempted, including all release architectures and several
unofficial ports. It might fail on non-Linux kernels or non-GNU libc,
but if it does, our build on those platforms would have been using the
wrong value for `SIZEOF_VOIDP` already, so it'll only be detecting a
pre-existing bug.
Signed-off-by: Simon McVittie <smcv@collabora.com>
---
test/testautomation_stdlib.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/test/testautomation_stdlib.c b/test/testautomation_stdlib.c
index 30abf0a..1d10d80 100644
--- a/test/testautomation_stdlib.c
+++ b/test/testautomation_stdlib.c
@@ -5,8 +5,12 @@
#include <stdio.h>
#include "SDL.h"
+#include "SDL_config.h"
#include "SDL_test.h"
+/* Compile-time assertions: even better than runtime assertions! */
+SDL_COMPILE_TIME_ASSERT(SIZEOF_VOIDP, SIZEOF_VOIDP == sizeof(void *));
+
/* Test case functions */
/**