[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#8695) _sleep is deprecated



quanah@openldap.org wrote:
> Full_Name: Quanah Gibson-Mount
> Version: 2.4.45
> OS: Windows 10 64-bit
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (47.208.148.239)
> 
> 
> When building OpenLDAP, we find:
> 
> C:/msys64/home/build/sold-master/openldap/tests/progs/slapd-read.c: In function
> 'do_read':
> C:/msys64/home/build/sold-master/openldap/tests/progs/slapd-read.c:384:11:
> warning: '_sleep' is deprecated [-Wdeprecated-declarations]
>            sleep( delay );
>            ^~~~~
> In file included from
> C:/msys64/home/build/sold-master/openldap/include/ac/stdlib.h:26:0,
>                  from
> C:/msys64/home/build/sold-master/openldap/tests/progs/slapd-read.c:24:
> C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:613:24: note: declared
> here
>    _CRTIMP void __cdecl _sleep(unsigned long _Duration)
> __MINGW_ATTRIB_DEPRECATED;
>                         ^~~~~~
> 
> This comes from:
> 
> include/ac/unistd.h
> 
> The correct function call is Sleep
> 
> #ifdef _WIN32
> #define sleep Sleep
> #endif
> 
> should resolve it.
> 
> 
Need to be careful here. M$ says the function is supported as of Windows XP
https://docs.microsoft.com/en-us/windows/desktop/api/synchapi/nf-synchapi-sleep

but is not defined in any header files until Windows Vista. Any "fix" should only
use Sleep if the current M$ SDK is new enough; the rest of the code still builds
on Windows XP.

-- 
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/