comparison m4/time_h.m4 @ 17581:1a0eb4e01632

gettimeofday: fix C++ crosscompilation Never replace gmtime and localtime by macros when compiling with C++, this prevents <ctime> from being included. * m4/gettimeofday.m4 (gl_GETTIMEOFDAY_REPLACE_LOCALTIME): Do not define gmtime and localtime as preprocessor macros. Instead define some HAVE_GMTIME, HAVE_LOCALTIME, REPLACE_GMTIME, and REPLACE_LOCALTIME substitutions. * lib/time.in.h: Declare gmtime and localtime when needed. * m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): AC_SUBST HAVE_GMTIME, HAVE_LOCALTIME, REPLACE_GMTIME, and REPLACE_LOCALTIME. * modules/time: Depend on gettimeofday, and substitute the above variables in time.h.
author John W. Eaton <jwe@gnu.org>
date Tue, 17 Dec 2013 11:04:37 -0800
parents e542fd46ad6f
children 630472a8cafd
comparison
equal deleted inserted replaced
17580:f20720b48838 17581:1a0eb4e01632
94 GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME]) 94 GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
95 GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM]) 95 GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
96 GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R]) 96 GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
97 dnl Assume proper GNU behavior unless another module says otherwise. 97 dnl Assume proper GNU behavior unless another module says otherwise.
98 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) 98 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R])
99 HAVE_GMTIME=1; AC_SUBST([HAVE_GMTIME])
100 HAVE_LOCALTIME=1; AC_SUBST([HAVE_LOCALTIME])
99 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) 101 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP])
100 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) 102 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
101 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) 103 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
102 dnl If another module says to replace or to not replace, do that. 104 dnl If another module says to replace or to not replace, do that.
103 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; 105 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
104 dnl this lets maintainers check for portability. 106 dnl this lets maintainers check for portability.
107 REPLACE_GMTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_GMTIME])
108 REPLACE_LOCALTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME])
105 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) 109 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
106 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) 110 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
107 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) 111 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
108 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) 112 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
109 ]) 113 ])