bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / code / Atom feed
* environ: Fix wrong autoconf test result in C++ mode
@ 2021-06-28  0:31 Bruno Haible
  0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2021-06-28  0:31 UTC (permalink / raw)
  To: bug-gnulib

The autoconf test
  checking if environ is properly declared... 
produces a wrong result (yes instead of no) in C++ mode, with g++ version 6
or newer and with clang++.

The reason is this error message:
g++:
  error: '<anonymous struct> environ', declared using anonymous type, is used but never defined
clang++:
  error: variable 'environ' is used but not defined in this translation unit, and cannot be defined in any other translation unit because its type does not have linkage

This patch fixes it.


2021-06-27  Bruno Haible  <bruno@clisp.org>

	environ: Fix wrong autoconf test result in C++ mode.
	* m4/environ.m4 (gt_CHECK_VAR_DECL): Use a typedef'ed type, not an
	anonymous type.

diff --git a/m4/environ.m4 b/m4/environ.m4
index d971770..ae53291 100644
--- a/m4/environ.m4
+++ b/m4/environ.m4
@@ -1,4 +1,4 @@
-# environ.m4 serial 7
+# environ.m4 serial 8
 dnl Copyright (C) 2001-2004, 2006-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -33,7 +33,8 @@ AC_DEFUN([gt_CHECK_VAR_DECL],
     [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM(
           [[$1
-            extern struct { int foo; } $2;]],
+            typedef struct { int foo; } foo_t;
+            extern foo_t $2;]],
           [[$2.foo = 1;]])],
        [gt_cv_var=no],
        [gt_cv_var=yes])])



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-28  0:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28  0:31 environ: Fix wrong autoconf test result in C++ mode Bruno Haible

Code repositories for project(s) associated with this inbox:

	../../../mirrors/gnulib.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).