Subject: Re: bug#11345: Fwd: lex-depend-cxx automake-1.12 test failure on Mac OS X 10.7.3 (Xcode-4.3.2)

From: Stefano Lattarini <[email-masked]>
Date: Thu, 26 Apr 2012 10:38:48 +0200

Hi Adam, thanks for the report.

On 04/26/2012 10:05 AM, Adam Mercer wrote:
> 
> I've been looking at getting the version of automake in MacPorts
> updated to automake-1.12 and I'm getting the following test failure:
> 
> FAIL: t/lex-depend-cxx
> ======================
>
> [SNIP]
>
> + make
> /bin/sh ./ylwrap joe.ll lex.yy.c joe.cc -- lex
> g++ -DPACKAGE_NAME=\"lex-depend-cxx\"
> -DPACKAGE_TARNAME=\"lex-depend-cxx\" -DPACKAGE_VERSION=\"1.0\"
> -DPACKAGE_STRING=\"lex-depend-cxx\ 1.0\" -DPACKAGE_BUGREPORT=\"\"
> -DPACKAGE_URL=\"\" -DPACKAGE=\"lex-depend-cxx\" -DVERSION=\"1.0\"
> -DYYTEXT_POINTER=1 -I.     -g -O2 -MT joe.o -
> MD -MP -MF .deps/joe.Tpo -c -o joe.o joe.cc
> In file included from /usr/include/c++/4.2.1/bits/os_defines.h:61,
>                  from /usr/include/c++/4.2.1/bits/c++config.h:41,
>                  from /usr/include/c++/4.2.1/cstdio:50,
>                  from my-hdr.hxx:2,
>                  from joe.ll:10:
> joe.ll:3: error: previous declaration of ‘int isatty(int)’ with ‘C++’ linkage
> /usr/include/unistd.h:502: error: conflicts with new declaration with
> ‘C’ linkage
> make: *** [joe.o] Error 1
> 
> This is with Mac OS 10.7.3 and Xcode-4.3.2
> 
Does the attached patch solves the problem for you?

Thanks,
  Stefano
>From 2eb5bde080ca3a74eabdb8e269a283da9b6cd4ca Mon Sep 17 00:00:00 2001
Message-Id: <2eb5bde08[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Thu, 26 Apr 2012 10:29:42 +0200
Subject: [PATCH] tests: fix a failure in Lex/C++ tests on Mac OS X

The <cstdio> header from Xcode-4.3.2 on Mac OS X 10.7.3 declares a 'isatty'
function with C++ linkage, that conflicts with our dummy definition of the
same function, which in turn is required to work around the absence of the
unistd.h header on MinGW (see commit 'v1.11-2138-gfeea090' of 11-04-2012).
So we tweak the affected tests to work around this new problem as well.

This fixes automake bug#11345.

* t/lex-clean-cxx.sh ($required): Since we are at it, add an explicit
'c++' requirement.
* t/lex-depend-cxx.sh ($required): Likewise.
(my-hdr.hxx): Don't include <cstdio>.  The "using namespace" directive
should still be enough to ensure the content of this header is not valid
C, albeit being of course valid C++.
Fix unrelated typos in comments.
(joe.ll): Adjust, by removing the call to 'printf'.

Signed-off-by: Stefano Lattarini <[email-masked]>
---
 t/lex-clean-cxx.sh  |    2 +-
 t/lex-depend-cxx.sh |    6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/t/lex-clean-cxx.sh b/t/lex-clean-cxx.sh
index 1c57524..d1a745b 100755
--- a/t/lex-clean-cxx.sh
+++ b/t/lex-clean-cxx.sh
@@ -20,7 +20,7 @@
 # "make maintainer-clean".
 # See also sister test 'lex-clean.test'.
 
-required=lex
+required='c++ lex'
 . ./defs || Exit 1
 
 cat >> configure.ac << 'END'
diff --git a/t/lex-depend-cxx.sh b/t/lex-depend-cxx.sh
index 490516f..7bdfdf9 100755
--- a/t/lex-depend-cxx.sh
+++ b/t/lex-depend-cxx.sh
@@ -17,7 +17,7 @@
 # Test to make sure dependencies work with Lex/C++.
 # Test synthesized from PR automake/6.
 
-required=lex
+required='c++ lex'
 . ./defs || Exit 1
 
 cat >> configure.ac << 'END'
@@ -61,7 +61,6 @@ int yywrap (void)
 }
 int main (int argc, char **argv)
 {
-  printf("Hello, World!\n");
   return 0;
 }
 END
@@ -69,8 +68,7 @@ END
 cp joe.ll moe.l++
 
 cat > my-hdr.hxx <<'END'
-// This header contains deliberetly invalid C (but valid C++)
-#include <cstdio>
+// This header contains deliberately invalid C (but valid C++).
 using namespace std;
 END
 
-- 
1.7.9.5