Re: [linux-minidisc] compiling libnetmd and netmdcli on windows


Am Mittwoch, den 14.09.2011, 23:51 +0200 schrieb Thomas Arp:
> O.K., here is my patch, please review.
Thanks for your patch.

> diff --git a/libnetmd/common.c b/libnetmd/common.c
> index 1f7b660..7e039ed 100644
> --- a/libnetmd/common.c
> +++ b/libnetmd/common.c
> @@ -62,7 +62,7 @@ static int netmd_poll(libusb_device_handle *dev,
> unsigned char *buf, int tries)
>          }
>  
>          if (i > 0) {
> -            sleep(1);
> +            usleep(200000);
>          }
>      }
usleep is probably not present in Visual C++, as it is a Unix function.
mingw most likely supports it for compatiblity reasons. If the code
should be even more portable, do use Sleep on Windows as you initially
suggested.

 
> -int min(int a,int b);
> +#ifndef min
> +    #define min(a,b) ((a)<(b)?(a):(b))
> +#endif
> +
As it seems that utils.h is only included inside libhimd, this is fine.
#define'ing min for public headers seems like a bad idea to me.

Your patch is fine except for the usleep quirk. I don't know whether we
care about non-GNU compilation on Windows, but if we do, we should not
use usleep on Windows (as I said up there).

Regards,
  Michael Karcher