From 166a6f789ccde8f6c96da43d4c3390d054a03115 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 26 Feb 2018 15:50:53 +0100 Subject: [PATCH] src/tools.c: fix compilation on Windows 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. --- src/tools.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tools.c b/src/tools.c index be63ac6..b9c85e1 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1,6 +1,6 @@ /* am7xxx - communication with AM7xxx based USB Pico Projectors and DPFs * - * Copyright (C) 2014 Antonio Ospite + * Copyright (C) 2014-2018 Antonio Ospite * * 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 @@ -16,8 +16,12 @@ * along with this program. If not, see . */ +#ifdef _WIN32 +#include +#else #include #include +#endif #include "tools.h" @@ -30,6 +34,9 @@ */ int msleep(unsigned long msecs) { +#ifdef _WIN32 + Sleep(msecs); +#else struct timespec delay; int ret; @@ -43,6 +50,7 @@ int msleep(unsigned long msecs) } if (ret == -1) return ret; +#endif return 0; } -- 2.1.4