From: Zack Weinberg Date: Wed, 4 Feb 2026 18:36:06 +0000 (-0500) Subject: AC_PROG_LEX: Be compatible with Solaris 10 lex’s handling of C++. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31eb3a33b09099298940c9cb192dc0790eab113c;p=thirdparty%2Fautoconf.git AC_PROG_LEX: Be compatible with Solaris 10 lex’s handling of C++. Solaris 10 lex (Software Generation Utilities (SGU) Solaris-ELF (4.0)) provides its own declaration of yywrap. When the generated scanner is compiled as C++, that declaration will *not* be tagged with `extern "C"` unless the preprocessor macro __EXTERN_C__ is defined using -D. The %{ %} block of the .l file is too late. Our test .l file also declares yywrap, and it unconditionally tags it with `extern "C"` when compiling as C++. Thus, we need to define __EXTERN_C__ or we’ll get a spurious compile error with this implementation of lex. This macro should be harmless with other implementations. sr #111381 * lib/autoconf/programs.m4 (_AC_PROG_LEX_YYTEXT_DECL): Add -D__EXTERN_C__=1 to CPPFLAGS while compiling test programs, for improved compatibility with Solaris 10 lex. --- diff --git a/lib/autoconf/programs.m4 b/lib/autoconf/programs.m4 index 332a72bc8..c7c176601 100644 --- a/lib/autoconf/programs.m4 +++ b/lib/autoconf/programs.m4 @@ -822,6 +822,14 @@ AS_IF([test "$ac_cv_prog_lex_root" = unknown], LEX=: LEXLIB=]) AC_SUBST([LEX_OUTPUT_ROOT], [$ac_cv_prog_lex_root])dnl +# When compiled as C++, the test lexer declares yywrap with extern "C". +# Solaris 10 lex (Software Generation Utilities (SGU) Solaris-ELF (4.0))'s +# scanner skeleton will provide a conflicting declaration of yywrap, +# *without* extern "C", unless we define this macro on the command line. +# The %{ %} block is not early enough for the definition to be effective. +ac_save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -D__EXTERN_C__=1" + AS_VAR_SET_IF([LEXLIB], [], [ AC_CACHE_CHECK([for lex library], [ac_cv_lib_lex], [ ac_save_LIBS="$LIBS" @@ -898,6 +906,7 @@ if test $ac_cv_prog_lex_yytext_pointer = yes; then not a 'char[]'.]) fi ]) +CPPFLAGS="$ac_save_CPPFLAGS" rm -f conftest.l $LEX_OUTPUT_ROOT.c ])# _AC_PROG_LEX_YYTEXT_DECL