octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: compile error on oct-env.cc in building octave-3.3.52+ on MinGW32


From: John W. Eaton
Subject: Re: compile error on oct-env.cc in building octave-3.3.52+ on MinGW32
Date: Wed, 22 Sep 2010 12:13:16 -0400

On 23-Sep-2010, Tatsuro MATSUOKA wrote:

| 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.

| > | ../../../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'
| > 
| > The unistd.h file from gnulib should provide gnulib::gethostname.  Are
| > the following defined in your configh.h file?
| > 
| >   GNULIB_TEST_GETHOSTNAME
| >   HAVE_GETHOSTNAME
| >   HAVE_RAW_DECL_GETHOSTNAME
| > 
| In config.h, I found the following:
| 
| /* Define to 1 when the gnulib module gethostname should be tested. */
| #define GNULIB_TEST_GETHOSTNAME 1
| 
| /* Define to 1 if you have the `gethostname' function. */
| /* #undef HAVE_GETHOSTNAME */
| 
| /* Define to 1 if gethostname is declared even after undefining macros. */
| /* #undef HAVE_RAW_DECL_GETHOSTNAME */

What do you have in the generated libgnu/unistd.h file?  I have:

  #if 1
  /* Return the standard host name of the machine.
     WARNING! The host name may or may not be fully qualified.

     Put up to LEN bytes of the host name into NAME.
     Null terminate it if the name is shorter than LEN.
     If the host name is longer than LEN, set errno = EINVAL and return -1.
     Return 0 if successful, otherwise set errno and return -1.  */
  # if 0
  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  #   undef gethostname
  #   define gethostname rpl_gethostname
  #  endif
  _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
                                      _GL_ARG_NONNULL ((1)));
  _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
  # else
  #  if !1
  _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
                                      _GL_ARG_NONNULL ((1)));
  #  endif
  /* Need to cast, because on Solaris 10 systems, the second parameter is
                                                        int len.  */
  _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
  # endif
  _GL_CXXALIASWARN (gethostname);
  #elif 0
  # undef gethostname
  # define gethostname 
gethostname_used_without_requesting_gnulib_module_gethostname
  #elif defined GNULIB_POSIXCHECK
  # undef gethostname
  # if HAVE_RAW_DECL_GETHOSTNAME
  _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
                   "use gnulib module gethostname for portability");
  # endif
  #endif

The corresponding code in gnulib/lib/unistd.in.h is

  #if @GNULIB_GETHOSTNAME@
  /* Return the standard host name of the machine.
     WARNING! The host name may or may not be fully qualified.

     Put up to LEN bytes of the host name into NAME.
     Null terminate it if the name is shorter than LEN.
     If the host name is longer than LEN, set errno = EINVAL and return -1.
     Return 0 if successful, otherwise set errno and return -1.  */
  # if @UNISTD_H_HAVE_WINSOCK2_H@
  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  #   undef gethostname
  #   define gethostname rpl_gethostname
  #  endif
  _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
                                      _GL_ARG_NONNULL ((1)));
  _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
  # else
  #  if address@hidden@
  _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
                                      _GL_ARG_NONNULL ((1)));
  #  endif
  /* Need to cast, because on Solaris 10 systems, the second parameter is
                                                        int len.  */
  _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
  # endif
  _GL_CXXALIASWARN (gethostname);
  #elif @UNISTD_H_HAVE_WINSOCK2_H@
  # undef gethostname
  # define gethostname 
gethostname_used_without_requesting_gnulib_module_gethostname
  #elif defined GNULIB_POSIXCHECK
  # undef gethostname
  # if HAVE_RAW_DECL_GETHOSTNAME
  _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
                   "use gnulib module gethostname for portability");
  # endif
  #endif

so you can see where the various "#if 1" and "#if 0" lines come from.
The values are substituted when you run configure (see config.status
for the values of these @NAME@ variables on your system.  Is
GNULIB_GETHOSTNAME defined to be 1 and substituted correctly for you?

Finally, could you add -save-temps to CXXFLAGS and compile oct-env.cc
and send the resulting oct-env.ii file?  That should show how all
these macros are expanded by the preprocessor.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]