BIC-MNI / libminc

libminc is the core library and API of the MINC toolkit
Other
19 stars 29 forks source link

warning: implicit declaration of function 'gettimeofday' #24

Closed seanm closed 9 years ago

seanm commented 9 years ago

git master has a warning:

volume_io/Prog_utils/time.c:141:9: warning: implicit declaration of function 'gettimeofday' is invalid in C99 [-Wimplicit-function-declaration]

time.c starts with:

#if HAVE_SYS_TIME_H
# include <sys/time.h>
#else
# include <time.h>
#endif

I've confirmed that I don't get into "#if HAVE_SYS_TIME_H" and also confirmed that #including <sys/time.h> fixes the warning.

I'm on OS X and building with CMake. I don't know enough about MINC's build system to know why HAVE_SYS_TIME_H is not true for me.

Help? :)

Thanks.

rdvincent commented 9 years ago

Is this really on master? I don't see gettimeofday() in the master branch.

In the short run, if you add a line to libminc/CMakeLists.txt on or around line 112:

CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H)

you will probably be ok, if HAVE_CLOCK_GETTIME is not set. Looking over this code, I think I need to rework the options to reflect current system dependencies. clock_gettime() and associated constants are defined in <time.h>, but gettimeofday() depends on <sys/time.h>.

rdvincent commented 9 years ago

@seanm Please see if the latest develop commit fixes the issue.

seanm commented 9 years ago

Ugh, indeed, I mean 'develop' branch... (I'm so used to mainline work being done in master.)

Your fix works, thanks!