[go: up one dir, main page]

Menu

#2 2.0 [_WIN32]: isinternal.h - fix lseek and ssize_t redefinition

Unstable (example)
accepted
nobody
None
5
2018-06-29
2018-06-29
No

When build with mingw64 thew following error occurs:

In file included from isdecimal.c:20:0:
isinternal.h:71:0: warning: "lseek" redefined [enabled by default]
 #define lseek(x, y, z)  _lseeki64(x, y, z)
 ^
In file included from C:/dev/mingw64/x86_64-w64-mingw32/include/unistd.h:10:0,
                 from isinternal.h:46,
                 from isdecimal.c:20:
C:/dev/mingw64/x86_64-w64-mingw32/include/io.h:341:0: note: this is the location of the previous definition
 #define lseek lseek64
 ^
 In file included from isdecimal.c:20:0:
isinternal.h:86:17: error: conflicting types for 'ssize_t'
 typedef int     ssize_t;
                 ^
In file included from C:/dev/mingw64/x86_64-w64-mingw32/include/io.h:9:0,
                 from C:/dev/mingw64/x86_64-w64-mingw32/include/unistd.h:10,
                 from isinternal.h:46,
                 from isdecimal.c:20:
C:/dev/mingw64/x86_64-w64-mingw32/include/crtdefs.h:45:35: note: previous declaration of 'ssize_t' was here
 __MINGW_EXTENSION typedef __int64 ssize_t;
                                   ^

fixed by

 #ifdef _WIN32
 #define WINDOWS_LEAN_AND_MEAN
 #include   <windows.h>
 #include   <io.h>
 #include   <sys/locking.h>
 #define    open(x, y, z)   _open(x, y, z)
 #define    read(x, y, z)   _read(x, y, z)
 #define    write(x, y, z)  _write(x, y, z)
+#ifndef lseek
 #ifdef WITH_LFS64
 #define    lseek(x, y, z)  _lseeki64(x, y, z)
 #else
 #define    lseek(x, y, z)  _lseek(x, y, z)
 #endif
+#endif
 #define    close(x)    _close(x)
 #define    unlink(x)   _unlink(x)
 #define fsync      _commit
 typedef int        uid_t;
 #ifndef    _PID_T_
 typedef int        pid_t;
 #endif
 #ifndef    _MODE_T_
 typedef unsigned short mode_t;
 #endif
-#ifndef    _SSIZE_T_
+#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
 typedef int        ssize_t;
 #endif
 #endif

Note: I plan to work on VBISAM in the second half of 2018 and will include the patch there.

Discussion


Log in to post a comment.