bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: environ: Fix wrong autoconf test result in C++ mode
Date: Mon, 28 Jun 2021 02:31:08 +0200	[thread overview]
Message-ID: <1704558.HPmjlsdhla@omega> (raw)

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])])



                 reply	other threads:[~2021-06-28  0:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1704558.HPmjlsdhla@omega \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).