views:

561

answers:

4

The compiler doesn't know where stat.h is?

Error: c:\Projects\ADC_HCI\mongoose.c(745) : error C2079: 'st' uses undefined struct '_stat64'

#include <sys/types.h>
#include <sys/stat.h>

static int
mg_stat(const char *path, struct mgstat *stp)
{
    struct _stat64 st; //<-- ERROR

    int  ok;
    wchar_t  wbuf[FILENAME_MAX];

    to_unicode(path, wbuf, ARRAY_SIZE(wbuf));
    if (_wstat64(wbuf, &st) == 0) {
     ok = 0;
     stp->size = st.st_size;
     stp->mtime = st.st_mtime;
     stp->is_directory = S_ISDIR(st.st_mode);
    } else {
     ok = -1;
    }

    return (ok);
}

...downloaded the files straight from the source.

+1  A: 

Change the _stat64 to stat64. At least in my Linux machines that's the name of the structure. I don't know if it is different in Windows.

rsarro
+3  A: 

See MSDN: _wstat64 takes a parameter of struct __stat64 (with two underscores). Redeclare your variable st to be of type struct __stat64.

Adam Rosenfield
+2  A: 

Note that neither _stat64 nor __stat64 is 'standard' in the sense of documented by any standard, such as POSIX. You would normally use struct stat; if you are worried about whether that will work with big files (over 2 GiB), then check what compilation options are required on your platform to obtain 'large file support'. For 64-bit machines and 64-bit compilations (not necessarily Windows 64), you usually don't need to worry. You can often obtain large file support using:

-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE

These are at least semi-standardized. Systems such as autoconf detect these things automatically (if you ask them to do so).

Jonathan Leffler
+1  A: 

I suggest you to sync to SVN trunk.

If you don't have SVN client, simply download two files: http://mongoose.googlecode.com/svn/trunk/mongoose.h (and .c file too)

The reason is that recently the code was refactored, and CRT _stat function was substituted with WinAPI one, GetFileAttributesExW().

valenok