Hi, Tatsuro MATSUOKA wrote: > Hello > > I am tring to build octave-3.3.52+ on MinGW (GCC-4.5.0) which uses the > gnulib. > In compliling oct-env.cc I have met the following error > > libtool: compile: g++ -shared-libgcc -DHAVE_CONFIG_H -I. > -I../../../hg/octave-work/liboctave -I.. -I/c/Programs/gpnewlib/include > -I/c/Programs/OctaveLibs/include -I/GnuWin32/include -I../libgnu > -I../../../hg/octave-work/libgnu -I../../../hg/octave-work/libcruft/misc > -I/c/Programs/gpnewlib/include -I/c/Programs/OctaveLibs/include > -I/GnuWin32/include -O3 -fomit-frame-pointer -DHAVE_CONFIG_H -mieee-fp > -IC:/Programs/GnuWin32/include -I/c/Programs/gpnewlib/include/freetype2 > -I/c/Programs/gpnewlib/include -IC:/Programs/gpnewlib/include -Wall -W > -Wshadow -Wold-style-cast -Wformat -O3 -fomit-frame-pointer -O3 > -fomit-frame-pointer -MT liboctave_la-oct-env.lo -MD -MP -MF > .deps/liboctave_la-oct-env.Tpo -c > ../../../hg/octave-work/liboctave/oct-env.cc -DDLL_EXPORT -DPIC -o > .libs/liboctave_la-oct-env.o > In file included from ../../../hg/octave-work/liboctave/oct-env.cc:61:0: > ../../../hg/octave-work/liboctave/oct-syscalls.h:61:62: error: macro > "waitpid" passed 4 arguments, but takes just 3 > ../../../hg/octave-work/liboctave/oct-syscalls.h:60:16: error: expected > identifier before numeric constant > ../../../hg/octave-work/liboctave/oct-syscalls.h:60:16: error: expected ',' > or '...' before numeric constant > ../../../hg/octave-work/liboctave/oct-env.cc: In member function > 'std::string octave_env::do_get_host_name() const': > ../../../hg/octave-work/liboctave/oct-env.cc:455:20: error: 'gethostname' > is not a member of 'gnulib' > > > I have reported the above in the octave-maintainer ML, > John suggested that for the first error > ****************** > | In sys/wait.h in the directory 'libgnu' in the build tree, I found > | > | ... > | > | # define waitpid(pid,statusp,options) _cwait (statusp, pid, WAIT_CHILD) > > We need to discuss this with the gnulib maintainers. For C++, it > would be helpful if this were a function instead of a macro. > ****************** > In file included from ../../../hg/octave-work/liboctave/oct-env.cc:61:0: > ../../../hg/octave-work/liboctave/oct-syscalls.h:61:62: error: macro > "waitpid" passed 4 arguments, but takes just 3 > > In oct-syscalls.h, there defined > > 60: static pid_t waitpid (pid_t, int *status, int); > 61: static pid_t waitpid (pid_t, int *status, int, std::string&); > *************** > > Perhaps John pointed for line 61 of oct-syscalls.h. > ********* > For C++, it > would be helpful if this were a function instead of a macro. > ***********
Thanks for the report. Indeed, for C++ it's needed to make 'waitpid' a function instead of a macro. Unfortunately an inline function in sys_wait.in.h won't do it (it leads to an assembler error message on mingw). So I move this function's definition to a separate file. 2010-09-29 Bruno Haible <[email protected]> New module 'waitpid'. * lib/waitpid.c: New file, extracted from lib/sys_wait.in.h. * lib/sys_wait.in.h: Include <sys/types.h>, c++defs.h, warn-on-use.h. Don't include <process.h>. (waitpid): Declare only, using modern idiom. * m4/waitpid.m4: New file. * m4/sys_wait_h.m4 (gl_SYS_WAIT_H): Check whether waitpid is declared. * modules/waitpid: New file. * modules/sys_wait (Depends-on): Add c++defs, warn-on-use, waitpid. (Makefile.am): Update. Reported by Tatsuro MATSUOKA <[email protected]>. ================================ lib/waitpid.c ================================ /* Wait for process state change. Copyright (C) 2001-2003, 2005-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include <config.h> /* Specification. */ #include <sys/wait.h> /* Implementation for native Win32 systems. */ #include <process.h> /* for _cwait, WAIT_CHILD */ pid_t waitpid (pid_t pid, int *statusp, int options) { return _cwait (statusp, pid, WAIT_CHILD); } ================================ m4/waitpid.m4 ================================ # waitpid.m4 serial 1 dnl Copyright (C) 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, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_WAITPID], [ AC_REQUIRE([AC_CANONICAL_HOST]) case $host_os in mingw*) AC_LIBOBJ([waitpid]) ;; esac ]) =============================== modules/waitpid =============================== Description: waitpid() function: wait for process state change Files: lib/waitpid.c m4/waitpid.m4 Depends-on: sys_wait configure.ac: gl_FUNC_WAITPID Makefile.am: Include: <sys/wait.h> License: LGPLv2+ Maintainer: Bruno Haible =============================================================================== --- lib/sys_wait.in.h.orig Wed Sep 29 13:15:34 2010 +++ lib/sys_wait.in.h Wed Sep 29 13:10:32 2010 @@ -30,6 +30,15 @@ #ifndef _GL_SYS_WAIT_H #define _GL_SYS_WAIT_H +/* Get pid_t. */ +#include <sys/types.h> + + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + + #if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) /* Unix API. */ @@ -71,24 +80,11 @@ # define WCOREDUMP(x) ((x) & 0x80) # endif -# ifdef __cplusplus -extern "C" { -# endif - -/* Declarations of functions. */ - -# ifdef __cplusplus -} -# endif - #else /* Native Windows API. */ -# include <process.h> /* for _cwait, WAIT_CHILD */ # include <signal.h> /* for SIGTERM */ -# define waitpid(pid,statusp,options) _cwait (statusp, pid, WAIT_CHILD) - /* The following macros apply to an argument x, that is a status of a process, as returned by waitpid() or, equivalently, _cwait() or GetExitCodeProcess(). This value is simply an 'int', not composed of bit fields. */ @@ -111,5 +107,29 @@ #endif +#ifdef __cplusplus +extern "C" { +#endif + +/* Declarations of functions. */ + +#if 1 /* @GNULIB_WAITPID@ */ +# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +_GL_FUNCDECL_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options)); +# endif +_GL_CXXALIAS_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options)); +_GL_CXXALIASWARN (waitpid); +#elif defined GNULIB_POSIXCHECK +# undef waitpid +# if HAVE_RAW_DECL_WAITPID +_GL_WARN_ON_USE (waitpid, "waitpid is unportable - " + "use gnulib module sys_wait for portability"); +# endif +#endif + +#ifdef __cplusplus +} +#endif + #endif /* _GL_SYS_WAIT_H */ #endif /* _GL_SYS_WAIT_H */ --- m4/sys_wait_h.m4.orig Wed Sep 29 13:15:34 2010 +++ m4/sys_wait_h.m4 Wed Sep 29 13:15:32 2010 @@ -1,4 +1,4 @@ -# sys_wait_h.m4 serial 4 +# sys_wait_h.m4 serial 5 dnl Copyright (C) 2008-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, @@ -10,6 +10,11 @@ dnl <sys/wait.h> is always overridden, because of GNULIB_POSIXCHECK. gl_CHECK_NEXT_HEADERS([sys/wait.h]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include <sys/wait.h>]], + [waitpid]) ]) AC_DEFUN([gl_SYS_WAIT_MODULE_INDICATOR], --- modules/sys_wait.orig Wed Sep 29 13:15:34 2010 +++ modules/sys_wait Wed Sep 29 12:58:22 2010 @@ -6,7 +6,10 @@ m4/sys_wait_h.m4 Depends-on: +c++defs include_next +warn-on-use +waitpid configure.ac: gl_SYS_WAIT_H @@ -17,13 +20,15 @@ # We need the following in order to create <sys/wait.h> when the system # has one that is incomplete. -sys/wait.h: sys_wait.in.h +sys/wait.h: sys_wait.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $...@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_SYS_WAIT_H''@|$(NEXT_SYS_WAIT_H)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/sys_wait.in.h; \ } > $...@-t && \ mv $...@-t $@
