[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
environ: Fix wrong autoconf test result in C++ mode
From: |
Bruno Haible |
Subject: |
environ: Fix wrong autoconf test result in C++ mode |
Date: |
Mon, 28 Jun 2021 02:31:08 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) |
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])])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- environ: Fix wrong autoconf test result in C++ mode,
Bruno Haible <=