http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47802
--- Comment #2 from dave at hiauly1 dot hia.nrc.ca 2011-02-18 20:56:54 UTC --- > Is there no way to get a posix compliant ctime? Alternatively, we'll need > autoconf magic to detect the extra arg. I know at one time it was relatively > common, so autoconf magic might be around somewhere. Assuming it is you just > have to do something like > > > #if defined (oddballctime) > *date = ctime_r (&now, cbuf, CSZ); > #else > *date = ctime_r (&now, cbuf); > #endif Using ctime_r is a bit of a can of worms. The GNU autoconf manual recommends not using ctime_r unless the inputs are known to be within certain limits. It seems HP-UX and Solaris have both forms. In the HP-UX 11 case, which form is used at compilation time depends on _PTHREADS_DRAFT4: # ifndef _PTHREADS_DRAFT4 extern char *ctime_r(const __time_t *, char *); # else /* _PTHREADS_DRAFT4 */ extern int ctime_r(const __time_t *, char *, int); # endif /* _PTHREADS_DRAFT4 */ Potential autoconf test: # ctime_r -- # # There are two versions of ctime_r, one of which takes a buffer length as a # third argument, and one which only takes two arguments. (There is also a # difference in return values, but we handle that in the code itself.) AC_CHECK_FUNCS(ctime_r) if test "$ac_cv_func_ctime_r" = "yes"; then AC_CACHE_CHECK([for 2 or 3 argument version of ctime_r], db_cv_ctime_r_3arg, [ AC_TRY_LINK([ #include <time.h>], [ ctime_r(NULL, NULL, 100); ], [db_cv_ctime_r_3arg="3-argument"], [db_cv_ctime_r_3arg="2-argument"])]) fi if test "$db_cv_ctime_r_3arg" = "3-argument"; then AC_DEFINE(HAVE_CTIME_R_3ARG) AH_TEMPLATE(HAVE_CTIME_R_3ARG, [Define to 1 if ctime_r takes a buffer length as a third argument.]) fi Dave