]> Savannah Git Hosting - gnulib.git/commitdiff
ffs: Ensure declaration on mingw.
authorBruno Haible <bruno@clisp.org>
Mon, 16 Jul 2018 22:49:06 +0000 (00:49 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 16 Jul 2018 22:50:31 +0000 (00:50 +0200)
Reported by Daniel P. BerrangĂ© <berrange@redhat.com>
in https://lists.gnu.org/archive/html/bug-gnulib/2018-07/msg00061.html.

* m4/ffs.m4 (gl_FUNC_FFS): Check whether ffs() not only exists but is
also declared.

ChangeLog
m4/ffs.m4

index 3d89a67d696b73afd931c2f76c692cfe12635106..ecb9e48f655a0dde47a104eec26e9d0524eb09db 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2018-07-16  Bruno Haible  <bruno@clisp.org>
+
+       ffs: Ensure declaration on mingw.
+       Reported by Daniel P. BerrangĂ© <berrange@redhat.com>
+       in https://lists.gnu.org/archive/html/bug-gnulib/2018-07/msg00061.html.
+       * m4/ffs.m4 (gl_FUNC_FFS): Check whether ffs() not only exists but is
+       also declared.
+
 2018-07-13  Paul Eggert  <eggert@cs.ucla.edu>
 
        regex-tests: add dependency
index 78b13ee685f10f41caa21e4dd39aadae9b71d8bf..a305f2b490b2e6b1d8bc7475e0fe776c6f6e6837 100644 (file)
--- a/m4/ffs.m4
+++ b/m4/ffs.m4
@@ -1,4 +1,4 @@
-# ffs.m4 serial 3
+# ffs.m4 serial 4
 dnl Copyright (C) 2011-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,13 +10,18 @@ AC_DEFUN([gl_FUNC_FFS],
 
   dnl We can't use AC_CHECK_FUNC here, because ffs() is defined as a
   dnl static inline function when compiling for Android 4.2 or older.
+  dnl But require that ffs() is declared; otherwise we may be using
+  dnl the GCC built-in function, which leads to warnings
+  dnl "warning: implicit declaration of function 'ffs'".
   AC_CACHE_CHECK([for ffs], [gl_cv_func_ffs],
     [AC_LINK_IFELSE(
        [AC_LANG_PROGRAM(
           [[#include <strings.h>
             int x;
           ]],
-          [[return ffs(x);]])
+          [[int (*func) (int) = ffs;
+            return func (x);
+          ]])
        ],
        [gl_cv_func_ffs=yes],
        [gl_cv_func_ffs=no])