Completely changed answer:
SUGGESTIONS:
1) Make sure you #include these headers:
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
2) Cast your pointer to "const"
time = localtime((const time_t *)&file->st_mtime);
3) Post back what happens
=====================================================
ADDITIONAL SUGGESTIONS:
1) Please read these two links:
Since kernel 2.5.48, the stat structure supports nanosecond resolution
for the three file timestamp fields. Glibc exposes the nanosecond
component of each field using names of the form st_atim.tv_nsec if the
_BSD_SOURCE or _SVID_SOURCE feature test macro is defined. These fields are specified in POSIX.1-2008, and, starting with version 2.12,
glibc also exposes these field names if _POSIX_C_SOURCE is defined
with the value 200809L or greater, or _XOPEN_SOURCE is defined with
the value 700 or greater. If none of the aforementioned macros are
defined, then the nanosecond values are exposed with names of the form
st_atimensec. On file systems that do not support subsecond
timestamps, the nanosecond fields are returned with the value 0.
2) Clearly, the makefile (that "works") has a #define that Eclipse doesn't, or vice versa.
Probably either/both _POSIX_C_SOURCE and/or _XOPEN_SOURCE.
Run this command to see what exists in the command line (makefile?) environment:
gcc -dM -E - < /dev/null | less
3) Please post back what you find!