libgit2/libgit2 — Issue #542: _SSIZE_T_DEFINED is missing from mingw.org GCC builds
Author: luislavena
Created: 2012-01-26 20:06:58+00:00
State: open

Hello,

This is related to issue #275 which was fixed in 22c30464624f0760d85668df9773fe4882ee20a4 but it solved mingw64 issue which defines `_SSIZE_T_DEFINED`

mingw.org builds of GCC (both 4.5.2 and 4.6.2) do not define `_SSIZE_T_DEFINED` and because of that, compilation fails:

```
[ 0%] Building C object CMakeFiles/git2.dir/src/attr.c.obj
In file included from c:/Users/Luis/Projects/oss/libgit2/libgit2/src/hashtable.h:13:0,
from c:/Users/Luis/Projects/oss/libgit2/libgit2/src/repository.h:16,
from c:/Users/Luis/Projects/oss/libgit2/libgit2/src/attr.c:1:
c:/Users/Luis/Projects/oss/libgit2/libgit2/src/common.h:37:17: error: conflicting types for 'ssize_t'
c:\users\luis\tools\devkit\4.6.2\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../include/sys/types.h:
118:18: note: previous declaration of 'ssize_t' was here
make[2]: *** [CMakeFiles/git2.dir/src/attr.c.obj] Error 1
```

I think the following change under `mingw-compat.h` can solve the issue and keep everybody happy:

```diff
diff --git a/src/win32/mingw-compat.h b/src/win32/mingw-compat.h
index 7207d88..03a1f9f 100644
--- a/src/win32/mingw-compat.h
+++ b/src/win32/mingw-compat.h
@@ -19,6 +19,11 @@
# define S_IFLNK _S_IFLNK
# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)

+/* mingw.org lacks _SSIZE_T_DEFINED */
+# ifndef _SSIZE_T_DEFINED
+# define _SSIZE_T_DEFINED
+# endif
+
#endif

#endif /* INCLUDE_mingw_compat__ */

```

There are other issues when linking, but that is a different issue.

Thank you.