]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
stdcountof-h tests: Fix link error on MSVC 14 (regression 2025-06-07).
authorBruno Haible <bruno@clisp.org>
Sun, 12 Oct 2025 11:31:49 +0000 (13:31 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 12 Oct 2025 11:31:49 +0000 (13:31 +0200)
* tests/test-stdcountof-h.c (a, b, c): Define as variables on MSVC.

ChangeLog
tests/test-stdcountof-h.c

index 07f0503f84fbb648dfa3425f1a1595181ff86616..932e94c63067a22abd5b0bdc012dc871a991dadd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2025-10-12  Bruno Haible  <bruno@clisp.org>
+
+       stdcountof-h tests: Fix link error on MSVC 14 (regression 2025-06-07).
+       * tests/test-stdcountof-h.c (a, b, c): Define as variables on MSVC.
+
 2025-10-10  Collin Funk  <collin.funk1@gmail.com>
 
        getline tests: Add a test for the glibc bug.
index 77cfbc4dec4580355075e0dc3b9fcf8a26f5f557..615cccda16240c787eb19443d36a2f528b339752 100644 (file)
@@ -105,3 +105,12 @@ main ()
 
   return test_exit_status;
 }
+
+/* A definition of the variables a, b, c is not required by ISO C, because
+   these identifiers are only used as part of 'sizeof' expressions whose
+   results are integer expressions.  See ISO C 23 ยง 6.9.1.(5).  However,
+   MSVC 14 generates actual references to these variables.  We thus need
+   to define these variables; otherwise we get link errors.  */
+#if defined _MSC_VER && !defined __clang__
+int a, b, c;
+#endif