haiwen/ccnet — pull request #11 by drobin (2013-11-12 10:09:43+00:00)
Title: MinGW: Fix compilation error

It's me again! :-)

Well, I try to to compile the Seafile-client for Windows using your build-msi.py (from the seafile repository) with MinGW 4.8.1. Compiling lib/rsa.c fails with the following error:

```
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -mms-bitfields -Ic:/gtk+/include/glib-2.0 -Ic:/gtk+/lib/glib-2.0/include -I../include -I../include/ccnet -I../lib -I../include -DG_LOG_DOMAIN=\"Ccnet\" -mms-bitfields -Ic:/seafile-msi-build/usr/include -Ic:/seafile-msi-build/usr/include/searpc -Ic:/gtk+/include/glib-2.0 -Ic:/gtk+/lib/glib-2.0/include -D__MSVCRT_VERSION__=0x0601 -Wall -DCCNET_SOURCE_COMMIT_ID=\"2da9529a7f0a2024c58c0848062375f675dc1269\" -g -fno-omit-frame-pointer -DSEAFILE_CLIENT_VERSION=\"2.0.7\" -I/c/seafile-msi-build/usr/include -IC:/MinGW/msys/1.0/include -I/usr/local/include -g -O2 -MT rsa.lo -MD -MP -MF .deps/rsa.Tpo -c rsa.c -DDLL_EXPORT -DPIC -o .libs/rsa.o
In file included from rsa.c:11:0:
rsa.h:28:27: error: unknown type name 'u_int'
RSA* generate_private_key(u_int bits);
^
make[3]: *** [rsa.lo] Error 1
```
AFAIK the `u_int` type is somewhere defined in `winsock2.h` (on MinGW).

For portability is suggest to change the datatype of the `bits` argument from `u_int` to `int`. Since generate_private_key() is a wrapper around the RSA_generate_key function and RSA_generate_key expects an int as the first argument, it is safe to change `u_int` to `int`.

Any comments?