bug-gnulib
[Top][All Lists]
Advanced

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

double-include include_next fix for Solaris 8, Sun Studio 11


From: Paul Eggert
Subject: double-include include_next fix for Solaris 8, Sun Studio 11
Date: Sat, 23 Jun 2007 13:01:44 -0700
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

I ran into a problem with gnulib on Solaris 8 with Sun Studio 11,
which resulted from the combination of the double-include patch of
<http://lists.gnu.org/archive/html/bug-gnulib/2007-05/msg00186.html>
and the recent #include_next patch of
<http://lists.gnu.org/archive/html/bug-gnulib/2007-06/msg00157.html>.
The problem is that Solaris 8 <time.h> eventually includes itself
recursively.  But the recursive inclusion resolves to gnulib time.h.
Gnulib assumes that #include "/usr/include/time.h" will define
struct timespec, but in this inner context that's not true, since
/usr/include/time.h does nothing if it is already in the process of
being included.

I installed the following patch, which fixes the problem for Solaris
8.  I don't have easy access to mingw, but if this idea also works on
mingw then perhaps we should use a similar solution for the other .h
files, as it is a bit simpler.

2007-06-23  Paul Eggert  <address@hidden>

        * lib/time_.h: Port to Solaris 8 with Sun Studio 11, using a
        method that I hope also handles the double-include problem noted
        by Bruno Haible in
        <http://lists.gnu.org/archive/html/bug-gnulib/2007-05/msg00186.html>.

This diff is computed with 'diff -w' to avoid changes due only to
space-changes.

*** time_.h.~1.7.~      Wed Jun 20 10:00:43 2007
--- time_.h.~1.8~       Sat Jun 23 12:53:19 2007
***************
*** 18,39 ****
  
  /* Don't get in the way of glibc when it includes time.h merely to
     declare a few standard symbols, rather than to declare all the
!    symbols.  */
! #if defined __need_time_t || defined __need_clock_t || defined __need_timespec
  
  # @INCLUDE_NEXT@ @NEXT_TIME_H@
  
  #else
- /* Normal invocation convention.  */
  
! # if ! defined _GL_TIME_H
  
- /* The include_next requires a split double-inclusion guard.  */
  #  @INCLUDE_NEXT@ @NEXT_TIME_H@
  
- #  if ! defined _GL_TIME_H
- #   define _GL_TIME_H
- 
  #   ifdef __cplusplus
  extern "C" {
  #   endif
--- 18,38 ----
  
  /* Don't get in the way of glibc when it includes time.h merely to
     declare a few standard symbols, rather than to declare all the
!    symbols.  Also, Solaris 8 <time.h> eventually includes itself
!    recursively; if that is happening, just include the system <time.h>
!    without adding our own declarations.  */
! #if (defined __need_time_t || defined __need_clock_t \
!      || defined __need_timespec \
!      || defined _GL_TIME_H)
  
  # @INCLUDE_NEXT@ @NEXT_TIME_H@
  
  #else
  
! # define _GL_TIME_H
  
  # @INCLUDE_NEXT@ @NEXT_TIME_H@
  
  # ifdef __cplusplus
  extern "C" {
  # endif
*************** time_t timegm (struct tm *__tm);
*** 112,117 ****
  }
  #   endif
  
- #  endif /* _GL_TIME_H */
- # endif /* _GL_TIME_H */
  #endif
--- 111,114 ----




reply via email to

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