no member named 'st_mtim' in 'struct stat'
Brought to you by:
bkorb
autogen 5.18.14 fails to build on macOS High Sierra (10.13), due to this problem:
./expExtract.c:59:47: error: no member named 'st_mtim' in 'struct stat'
if (time_is_before(outfile_time, stbf.st_mtime))
~~~~ ^
./autogen.h:428:18: note: expanded from macro 'st_mtime'
#define st_mtime st_mtim
^
./autogen.h:421:21: note: expanded from macro 'time_is_before'
((_f).tv_sec < (_s).tv_sec) \
^~
I've seen similar errors with other projects.
It builds fine on macOS Sierra (10.12) and OS X El Capitan (10.11).
So I need to add a "how is the mod time field spelled" config macro. Lovely. Thank you.
if I could get the structure used by OS/X, I'd appreciate. Thanks.
On macOS, the
statstructure in sys/stat.h contains a reference to__DARWIN_STRUCT_STAT64_TIMESwhich is defined like this:And then outside of the
statstructure there is this:So it looks like depending on the definitions of
_POSIX_C_SOURCEand_DARWIN_C_SOURCE, thestatstruct might contain anst_mtimespecstructure withtv_secandtv_nsecfields, withst_mtimebeing a macro referring to thetv_secfield, orstatmight directly containst_mtimeandst_mtimensecfields.I don't fully understand the implications of setting
_POSIX_C_SOURCEor_DARWIN_C_SOURCE, or under what circumstances they might already be set. I know that there are many other places in the system headers where behavior changes depending on those.I found an online manpage for
stat(2)on Debian Linux where the structures are defined as:And there are macros for accessing these times as seconds:
I found a manpage for
stat(2)on FreeBSD which appers to allow the use of either thest_*timname or thest_*timespecname, via#defines.So, if you just wanted the times in seconds, you should just use
st_atime,st_mtime,st_ctimeand it will work on any system. But since it looks like your code wants nanoseconds too, you'll have to figure out how to do that on the current platform.The asterisk project's code has a method for doing this; perhaps you could adapt it:
https://github.com/asterisk/asterisk/blob/master/configure.ac#L742
https://github.com/asterisk/asterisk/blob/master/main/config.c#L1580
You should probably remove these lines from your code, which redefine
st_atime,st_mtime, andst_ctimeto have nonstandard meanings:running ./configure with
ac_cv_func_utimensat=nois a workaround to build on 10.13. As I understand it, autogen then builds as it used to on systems with no utimensat.I am attending to this. I cannot build autogen on Linux at the moment. The autotools suite has made "improvements" to the way it handles compiler generated dependency files. That broke my build because autogen also creates dependency files, but automake's new method is incompatible and the emitted error message is completely inscrutable. Basically, "Oops! Something went wrong and we have no idea" is the message. It takes time. Terribly sorry.
gnulib has this comment in the "stat-time.m4":
st_atim.tv_nsec - Linux, Solaris, Cygwin
st_atimespec.tv_nsec - FreeBSD, NetBSD, if ! defined _POSIX_SOURCE
st_atimensec - FreeBSD, NetBSD, if defined _POSIX_SOURCE
st_atim.st__tim.tv_nsec - UnixWare (at least 2.1.2 through 7.1)
So everybody has their own favorite flavor. I'll pull the gnulib stuff.
I've updated the code to use the current POSIX specs. This ought to resolve the problem.