Similarly for the mkstemp function: I'm seeing this error: ../gllib/stdlib.h:600: error: `mkstemp' was not declared in this scope
> Here it becomes necessary to distinguish the two cases, like we do for many > other functions. Likewise here. This fixes it. 2010-04-03 Bruno Haible <br...@clisp.org> mkstemp: Fix C++ test error on mingw. * lib/stdlib.in.h (mkstemp): Use modern idiom. * m4/mkstemp.m4 (gl_FUNC_MKSTEMP): Distinguish the case that the function is missing and that it needs to be replaced. * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize HAVE_MKSTEMP. * modules/stdlib (Makefile.am): Substitute HAVE_MKSTEMP. --- lib/stdlib.in.h.orig Sat Apr 3 13:42:15 2010 +++ lib/stdlib.in.h Sat Apr 3 13:32:01 2010 @@ -329,6 +329,9 @@ _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); # else +# if ! @HAVE_MKSTEMP@ +_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); +# endif _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); # endif _GL_CXXALIASWARN (mkstemp); --- m4/mkstemp.m4.orig Sat Apr 3 13:42:15 2010 +++ m4/mkstemp.m4 Sat Apr 3 13:34:10 2010 @@ -1,4 +1,4 @@ -#serial 17 +#serial 18 # Copyright (C) 2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -16,35 +16,41 @@ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([AC_SYS_LARGEFILE]) - AC_CACHE_CHECK([for working mkstemp], - [gl_cv_func_working_mkstemp], - [ - mkdir conftest.mkstemp - AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [AC_INCLUDES_DEFAULT], - [[int i; - off_t large = (off_t) 4294967295u; - if (large < 0) - large = 2147483647; - for (i = 0; i < 70; i++) - { - char templ[] = "conftest.mkstemp/coXXXXXX"; - int (*mkstemp_function) (char *) = mkstemp; - int fd = mkstemp_function (templ); - if (fd < 0 || lseek (fd, large, SEEK_SET) != large) - return 1; - close (fd); - } - return 0;]])], - [gl_cv_func_working_mkstemp=yes], - [gl_cv_func_working_mkstemp=no], - [gl_cv_func_working_mkstemp=no]) - rm -rf conftest.mkstemp - ]) - - if test $gl_cv_func_working_mkstemp != yes; then - REPLACE_MKSTEMP=1 + AC_CHECK_FUNCS_ONCE([mkstemp]) + if test $ac_cv_func_mkstemp = yes; then + AC_CACHE_CHECK([for working mkstemp], + [gl_cv_func_working_mkstemp], + [ + mkdir conftest.mkstemp + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT], + [[int i; + off_t large = (off_t) 4294967295u; + if (large < 0) + large = 2147483647; + for (i = 0; i < 70; i++) + { + char templ[] = "conftest.mkstemp/coXXXXXX"; + int (*mkstemp_function) (char *) = mkstemp; + int fd = mkstemp_function (templ); + if (fd < 0 || lseek (fd, large, SEEK_SET) != large) + return 1; + close (fd); + } + return 0;]])], + [gl_cv_func_working_mkstemp=yes], + [gl_cv_func_working_mkstemp=no], + [gl_cv_func_working_mkstemp=no]) + rm -rf conftest.mkstemp + ]) + if test $gl_cv_func_working_mkstemp != yes; then + REPLACE_MKSTEMP=1 + AC_LIBOBJ([mkstemp]) + gl_PREREQ_MKSTEMP + fi + else + HAVE_MKSTEMP=0 AC_LIBOBJ([mkstemp]) gl_PREREQ_MKSTEMP fi --- m4/stdlib_h.m4.orig Sat Apr 3 13:42:15 2010 +++ m4/stdlib_h.m4 Sat Apr 3 13:32:26 2010 @@ -1,4 +1,4 @@ -# stdlib_h.m4 serial 27 +# stdlib_h.m4 serial 28 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -85,6 +85,7 @@ HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) + HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP]) HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) --- modules/stdlib.orig Sat Apr 3 13:42:15 2010 +++ modules/stdlib Sat Apr 3 13:32:36 2010 @@ -62,6 +62,7 @@ -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ + -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \ -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \