[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PROPOSED 2/2] assert-h: prefer to ‘verify’
From: |
Bruno Haible |
Subject: |
Re: [PROPOSED 2/2] assert-h: prefer to ‘verify’ |
Date: |
Wed, 14 Sep 2022 03:05:02 +0200 |
Paul Eggert wrote:
> Where it’s easy, prefer ‘static_assert’ to ‘verify’,
Compiling a current GNU gettext with these patches on Cygwin and mingw
I get a compilation error:
/bin/sh ./libtool --tag=CXX --mode=compile x86_64-pc-cygwin-g++
-DIN_LIBASPRINTF -DHAVE_CONFIG_H -D__USE_MINGW_ANSI_STDIO=0 -I.
-I../../../gettext-runtime/libasprintf -Ignulib-lib
-I../../../gettext-runtime/libasprintf/gnulib-lib -I/usr/local/cygwin64/include
-Wall -g -O2 -c -o autosprintf.lo
../../../gettext-runtime/libasprintf/autosprintf.cc
libtool: compile: x86_64-pc-cygwin-g++ -DIN_LIBASPRINTF -DHAVE_CONFIG_H
-D__USE_MINGW_ANSI_STDIO=0 -I. -I../../../gettext-runtime/libasprintf
-Ignulib-lib -I../../../gettext-runtime/libasprintf/gnulib-lib
-I/usr/local/cygwin64/include -Wall -g -O2 -c
../../../gettext-runtime/libasprintf/autosprintf.cc -o autosprintf.o
In file included from ./config.h:1097:0,
from ../../../gettext-runtime/libasprintf/autosprintf.cc:18:
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/type_traits:1105:7: error:
expected identifier before 'sizeof'
static_assert(sizeof...(_Args) > 1,
^
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/type_traits:1105:7: error:
expected ',' or '...' before 'sizeof'
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/type_traits:2093:7: error:
expected identifier before 'sizeof'
static_assert(sizeof...(_Types) != 0, "At least one type is required");
^
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/type_traits:2093:7: error:
expected ',' or '...' before 'sizeof'
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/ptr_traits.h:114:7: error:
expected identifier before '!' token
static_assert(!is_same<element_type, __undefined>::value,
^
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/ptr_traits.h:114:7: error:
expected ',' or '...' before '!' token
In file included from /usr/include/features.h:12:0,
from gnulib-lib/wchar.h:66,
from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/cwchar:44,
from
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/postypes.h:40,
from
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/char_traits.h:40,
from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/string:40,
from ./autosprintf.h:35,
from ../../../gettext-runtime/libasprintf/autosprintf.cc:21:
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/utility:309:7: error: '_Num' is
not a type
static_assert( _Num >= 0,
^
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/utility:309:7: error: expected
',' or '...' before '>=' token
static_assert( _Num >= 0,
^
make[6]: *** [Makefile:1412: autosprintf.lo] Error 1
This patch fixes it.
2022-09-13 Bruno Haible <bruno@clisp.org>
verify: Avoid syntax error due to static_assert with GNU C++ 6.x.
* lib/verify.h (static_assert): Don't define in GNU C++ 6 or newer.
diff --git a/lib/verify.h b/lib/verify.h
index 0066d211b2..154a5b76bf 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -227,7 +227,8 @@ template <int w>
_GL_VERIFY (__VA_ARGS__, "static assertion failed", -)
# endif
# if (!defined static_assert \
- && __STDC_VERSION__ < 202311 && __cpp_static_assert < 201411)
+ && __STDC_VERSION__ < 202311 \
+ && __cpp_static_assert < 201411 && __GNUG__ < 6)
# define static_assert _Static_assert /* C11 requires this #define. */
# endif
#endif
- [PROPOSED 0/2] static_assert and C23, Paul Eggert, 2022/09/12
- [PROPOSED 1/2] assert-h: static_assert is a keyword in C23, Paul Eggert, 2022/09/12
- [PROPOSED 2/2] assert-h: prefer to ‘verify’, Paul Eggert, 2022/09/12
- Re: [PROPOSED 2/2] assert-h: prefer to ‘verify’,
Bruno Haible <=
- Re: [PROPOSED 2/2] assert-h: prefer to ‘verify’, Bruno Haible, 2022/09/14
- Re: [PROPOSED 2/2] assert-h: prefer to ‘verify’, Bruno Haible, 2022/09/14
- Re: [PROPOSED 2/2] assert-h: prefer to ‘verify’, Bruno Haible, 2022/09/14
- Re: [PROPOSED 0/2] static_assert and C23, Bruno Haible, 2022/09/13