]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
gettext.h: Avoid "warning: ISO C++ forbids variable length array" with -pedantic.
authorBruno Haible <bruno@clisp.org>
Tue, 15 Oct 2024 14:49:13 +0000 (16:49 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 15 Oct 2024 14:49:13 +0000 (16:49 +0200)
Both "g++ -pedantic" and "clang++ -pedantic" warn about use of VLAs.
Since we cannot distinguish "g++" from "g++ -pedantic" through a preprocessor
macro, it's best to not use a VLA in C++.

Reported by Jens Seidel <jensseidel@users.sf.net>
via <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=547798>
at <https://savannah.gnu.org/bugs/index.php?55149>.

* gnulib-local/lib/gettext.h (_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS): Define
to 0 in C++ mode.

gnulib-local/lib/gettext.h

index 3d3840f9fcde4080ce3aff097ea73a23ce6e9417..e385a30e487bd410c347cf0f7d1bb2d5d3246f76 100644 (file)
@@ -1,6 +1,5 @@
 /* Convenience header for conditional use of GNU <libintl.h>.
-   Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2020 Free Software
-   Foundation, Inc.
+   Copyright (C) 1995-2024 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -191,7 +190,8 @@ npgettext_aux (const char *domain,
    or may have security implications due to non-deterministic stack usage.  */
 
 #if (!defined GNULIB_NO_VLA \
-     && (((__GNUC__ >= 3 || defined __clang__) && !defined __STRICT_ANSI__) \
+     && (((__GNUC__ >= 3 || defined __clang__) \
+          && !defined __STRICT_ANSI__ && !defined __cplusplus) \
          /* || (__STDC_VERSION__ == 199901L && !defined __HP_cc)
             || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ ))
 # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1