tanakamura / waifu2x-converter-cpp

waifu2x(original : https://github.com/nagadomi/waifu2x) re-implementation in C++ using OpenCV
Other
319 stars 37 forks source link

Compilation failed on macOS #31

Open inflation opened 8 years ago

inflation commented 8 years ago

Hi, I found this error when I compiled it on macOS:

tmp/waifu2x-converter-cpp/src/common.cpp:201:13: error: no member named
      'st_mtim' in 'stat'
        if (src_st.st_mtim.tv_sec > dst_st.st_mtim.tv_sec) {
            ~~~~~~ ^
/tmp/waifu2x-converter-cpp/src/common.cpp:201:37: error: no member named
      'st_mtim' in 'stat'
        if (src_st.st_mtim.tv_sec > dst_st.st_mtim.tv_sec) {
                                    ~~~~~~ ^
/tmp/waifu2x-converter-cpp/src/common.cpp:205:13: error: no member named
      'st_mtim' in 'stat'
        if (src_st.st_mtim.tv_nsec > dst_st.st_mtim.tv_nsec) {
            ~~~~~~ ^
/tmp/waifu2x-converter-cpp/src/common.cpp:205:38: error: no member named
      'st_mtim' in 'stat'
        if (src_st.st_mtim.tv_nsec > dst_st.st_mtim.tv_nsec) {
                                     ~~~~~~ ^
4 errors generated.

I think it is a problem about the difference of stat library's implementation in macOS. So I searched for the manual, and changing it to st_mtime will allow it to compile. So can we make some check of the platform? Thanks.

mattpopovich commented 5 years ago

Seconded. Via Apple's developer pages:

struct stat {
         dev_t    st_dev;    /* device inode resides on */
         ino_t    st_ino;    /* inode's number */
         mode_t   st_mode;   /* inode protection mode */
         nlink_t  st_nlink;  /* number or hard links to the file */
         uid_t    st_uid;    /* user-id of owner */
         gid_t    st_gid;    /* group-id of owner */
         dev_t    st_rdev;   /* device type, for special file inode */
         struct timespec st_atimespec;  /* time of last access */
         struct timespec st_mtimespec;  /* time of last data modification */
         struct timespec st_ctimespec;  /* time of last file status change */
         off_t    st_size;   /* file size, in bytes */
         quad_t   st_blocks; /* blocks allocated for file */
         u_long   st_blksize;/* optimal file sys I/O ops blocksize */
         u_long   st_flags;  /* user defined flags for file */
         u_long   st_gen;    /* file generation number */
     };

I changed mine to st_mtimespec as was recommended here and could compile.