git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Silence iconv warnings on Leopard

From
Blake Ramsdell <blaker@gmail.com>
Date
Dec 7, 2007, 00:41 UTC
Message-ID
<985966520712061641y4eba054dj5dea1d0308d50b12@mail.gmail.com>
In-Reply-To
<alpine.LFD.0.9999.0712061628070.13796@woody.linux-foundation.org>
On Dec 6, 2007 4:30 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote:
Show 10 quoted lines
> Umm. Why not just make the test be whether the following compiles cleanly?
>
>         #include <iconv.h>
>
>         extern size_t iconv(iconv_t cd,
>           char **inbuf, size_t *inbytesleft,
>           char **outbuf, size_t *outbytesleft);
>
> because if the compiler has seen a "const char **inbuf", then it  should
> error out with a "conflicting types for 'iconv'" style message..
Yeah, this is what I did:
diff --git a/configure.ac b/configure.ac
index 5f8a15b..675d3e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -182,6 +182,29 @@ AC_SUBST(NEEDS_LIBICONV)
 AC_SUBST(NO_ICONV)
 test -n "$NEEDS_LIBICONV" && LIBS="$LIBS -liconv"
 #
+# Define OLD_ICONV if the iconv function prototype uses const** (Darwin and
+# some FreeBSD installations).
+AC_DEFUN([OLDICONVTEST_SRC], [
+#include <iconv.h>
+
+int main(void)
+{
+    char* value = "test";
+
+    (void) iconv (NULL, &value, NULL, NULL, NULL);
+}
+])
+AC_MSG_CHECKING([for old iconv])
+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Werror"
+AC_COMPILE_IFELSE(OLDICONVTEST_SRC,
+	[AC_MSG_RESULT([no])
+	OLD_ICONV=],
+	[AC_MSG_RESULT([yes])
+	OLD_ICONV=UnfortunatelyYes])
+CFLAGS="$old_CFLAGS"
+AC_SUBST(OLD_ICONV)
+#
 # Define NO_DEFLATE_BOUND if deflateBound is missing from zlib.
 AC_DEFUN([ZLIBTEST_SRC], [
 #include <zlib.h>

The problem is that AC_COMPILE_IFELSE doesn't barf on warnings, so I
had to put in the CFLAGS hack to do -Werror (this is what Jakub did
also, I think).

So if this isn't rude to use -Werror (which is probably gcc-specific
in one or more ways), then fine. If it is rude to use -Werror, then
yeah, there needs to be some check for the warning, which I confess in
my five minutes of learning autoconf I don't understand well enough to
say if it's possible.

Blake
-- 
Blake Ramsdell | http://www.blakeramsdell.com
Previous: Linus TorvaldsNext: Blake Ramsdell
Message 6 of 12 in “Silence iconv warnings on Leopard”
  1. Silence iconv warnings on LeopardWincent Colaiuta, Dec 6, 2007
  2. Blake RamsdellDec 6, 2007
  3. Jakub NarebskiDec 7, 2007
  4. Blake RamsdellDec 7, 2007
  5. Linus TorvaldsDec 7, 2007
  6. Blake RamsdellDec 7, 2007
  7. Blake RamsdellDec 7, 2007
  8. autoconf: Add test for OLD_ICONV (squelching compiler warning)Jakub Narebski, Dec 7, 2007
  9. Junio C HamanoDec 7, 2007
  10. Wincent ColaiutaDec 7, 2007
  11. Wincent ColaiutaDec 7, 2007
  12. Blake RamsdellDec 7, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.