On Windows nanosleep() is not available and compiling fails with the
following error:
CMakeFiles/am7xxx.dir/objects.a(tools.c.obj):tools.c:(.text+0x4a): undefined reference to `nanosleep'
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/am7xxx.dir/build.make:153: lib/libam7xxx.dll] Error 1
make[1]: *** [CMakeFiles/Makefile2:189: src/CMakeFiles/am7xxx.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
Using the native Windows function Sleep() fixes the error.
/* am7xxx - communication with AM7xxx based USB Pico Projectors and DPFs
*
/* am7xxx - communication with AM7xxx based USB Pico Projectors and DPFs
*
- * Copyright (C) 2014 Antonio Ospite <ao2@ao2.it>
+ * Copyright (C) 2014-2018 Antonio Ospite <ao2@ao2.it>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef _WIN32
+#include <windows.h>
+#else
#include <errno.h>
#include <time.h>
#include <errno.h>
#include <time.h>
*/
int msleep(unsigned long msecs)
{
*/
int msleep(unsigned long msecs)
{
+#ifdef _WIN32
+ Sleep(msecs);
+#else
struct timespec delay;
int ret;
struct timespec delay;
int ret;
}
if (ret == -1)
return ret;
}
if (ret == -1)
return ret;