1

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.

mpromonet
  • 11,326
  • 43
  • 62
  • 91
T.T.T.
  • 33,367
  • 47
  • 130
  • 168
  • 1
    Ask about it at the mongoose support group at http://groups.google.com/group/mongoose-users/topics - the maintainer is extremely helpful. –  Apr 27 '09 at 19:13
  • yeah, I just asked the group too.... – T.T.T. Apr 27 '09 at 19:16
  • 1
    I just looked at your post there - what kind of VS project are you using? IIRC, you need to build it as a multi-threaded console application. –  Apr 27 '09 at 19:28
  • I am compiling as /MT now as I will need that however, still have error. – T.T.T. Apr 27 '09 at 20:10
  • Someone pointed out _stat64 in stat.h is double underscore.... – T.T.T. Apr 27 '09 at 21:06

4 Answers4

3

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

Adam Rosenfield
  • 390,455
  • 97
  • 512
  • 589
2

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
  • 730,956
  • 141
  • 904
  • 1,278
1

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
  • 827
  • 7
  • 9
1

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
  • 566
  • 3
  • 6