bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems compiling 'getrandom' with MinGW


From: Bruno Haible
Subject: Re: Problems compiling 'getrandom' with MinGW
Date: Sat, 04 Jul 2020 04:02:09 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-179-generic; KDE/5.18.0; x86_64; ; )

> 2020-06-28  Bruno Haible  <bruno@clisp.org>
> 
>       getrandom: Fix compilation errors on older versions of mingw.

Oops, this patch produced compilation errors. Here's the fix.


2020-07-03  Bruno Haible  <bruno@clisp.org>

        getrandom: Fix compilation error on native Windows (regr. 2020-06-28).
        * lib/getrandom.c: Don't include <ntdef.h>. Instead, define NTSTATUS.
        * m4/getrandom.m4 (gl_FUNC_GETRANDOM): Include <windows.h> before
        <bcrypt.h>.

diff --git a/lib/getrandom.c b/lib/getrandom.c
index 030a78b..f8695ab 100644
--- a/lib/getrandom.c
+++ b/lib/getrandom.c
@@ -32,7 +32,7 @@
 # if HAVE_BCRYPT_H
 #  include <bcrypt.h>
 # else
-#  include <ntdef.h> /* NTSTATUS */
+#  define NTSTATUS LONG
 typedef void * BCRYPT_ALG_HANDLE;
 #  define BCRYPT_USE_SYSTEM_PREFERRED_RNG 0x00000002
 #  if HAVE_LIB_BCRYPT
diff --git a/m4/getrandom.m4 b/m4/getrandom.m4
index 2a0034b..424c2fa 100644
--- a/m4/getrandom.m4
+++ b/m4/getrandom.m4
@@ -1,4 +1,4 @@
-# getrandom.m4 serial 6
+# getrandom.m4 serial 7
 dnl Copyright 2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -36,7 +36,9 @@ AC_DEFUN([gl_FUNC_GETRANDOM],
 
   case "$host_os" in
     mingw*)
-      AC_CHECK_HEADERS([bcrypt.h])
+      AC_CHECK_HEADERS([bcrypt.h], [], [],
+        [[#include <windows.h>
+        ]])
       AC_CACHE_CHECK([whether the bcrypt library is guaranteed to be present],
         [gl_cv_lib_assume_bcrypt],
         [AC_COMPILE_IFELSE(




reply via email to

[Prev in Thread] Current Thread [Next in Thread]