Compiling a gnulib testdir on Mac OS X 10.5.8, I see this compilation error:

In file included from ../../gltests/test-mcel.c:19:
../../gltests/../gllib/mcel.h: In function 'mcel_isbasic':
../../gltests/../gllib/mcel.h:200: warning: comparison is always true due to 
limited range of data type
../../gltests/test-mcel.c: In function 'main':
../../gltests/test-mcel.c:74: warning: comparison is always true due to limited 
range of data type
../../gltests/test-mcel.c:116: error: nested functions are disabled, use 
-fnested-functions to re-enable
../../gltests/test-mcel.c:116: error: syntax error before '.' token
../../gltests/test-mcel.c:115: warning: unused variable 'ijk'
../../gltests/test-mcel.c:118: error: 'ijk' undeclared (first use in this 
function)
../../gltests/test-mcel.c:118: error: (Each undeclared identifier is reported 
only once
../../gltests/test-mcel.c:118: error: for each function it appears in.)
../../gltests/test-mcel.c:118: error: 'u' undeclared (first use in this 
function)
../../gltests/test-mcel.c:120: error: 'i' undeclared (first use in this 
function)
../../gltests/test-mcel.c: At top level:
../../gltests/test-mcel.c:137: error: syntax error before '}' token
make[4]: *** [test-mcel.o] Error 1

The syntax error in the line

          mbstate_t mbs = {0};

comes from the previous declaration

# define mbs u.m

in mcel.h. This patch fixes it.


2023-10-03  Bruno Haible  <br...@clisp.org>

        mcel: Fix compilation error in tests.
        * lib/mcel.h (mcel_scan): Undefine 'mbs' after use.

diff --git a/lib/mcel.h b/lib/mcel.h
index 54ae125957..b178c7aec9 100644
--- a/lib/mcel.h
+++ b/lib/mcel.h
@@ -249,6 +249,8 @@ mcel_scan (char const *p, char const *lim)
   char32_t ch;
   size_t len = mbrtoc32 (&ch, p, lim - p, &mbs);
 
+#undef mbs
+
   /* Any LEN with top bit set is an encoding error, as LEN == (size_t) -3
      is not supported and MB_LEN_MAX is small.  */
   if (_GL_UNLIKELY ((size_t) -1 / 2 < len))




Reply via email to