[Top][All Lists]

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

strerror_r-posix on MSVC

From: Bruno Haible
Subject: strerror_r-posix on MSVC
Date: Fri, 23 Sep 2011 00:16:54 +0200
User-agent: KMail/1.13.6 (Linux/; KDE/4.6.0; x86_64; ; )

The module 'strerror_r-posix' leads to a link error on MSVC, because it
uses snprintf() which does not exist on this platform.

The simplest solution would be to add a dependency to 'snprintf'. But that
would drag in vasnprintf.c, which is really overkill for the simple use of
snprintf() here. The simple and buggy _snprintf does it as well.

2011-09-22  Bruno Haible  <address@hidden>

        strerror_r-posix: Avoid a link error on MSVC.
        * m4/strerror_r.m4 (gl_PREREQ_STRERROR_R): Check for snprintf.
        * lib/strerror_r.c (snprintf): Define to _snprintf if it doesn't exist.

--- lib/strerror_r.c.orig       Fri Sep 23 00:11:32 2011
+++ lib/strerror_r.c    Fri Sep 23 00:07:08 2011
@@ -86,6 +86,12 @@
+/* On MSVC, there is no snprintf() function, just a _snprintf().
+   It is of lower quality, but sufficient for the simple use here.  */
+# define snprintf _snprintf
 /* Copy as much of MSG into BUF as possible, without corrupting errno.
    Return 0 if MSG fit in BUFLEN, otherwise return ERANGE.  */
 static int
--- m4/strerror_r.m4.orig       Fri Sep 23 00:11:32 2011
+++ m4/strerror_r.m4    Fri Sep 23 00:04:21 2011
@@ -1,4 +1,4 @@
-# strerror_r.m4 serial 13
+# strerror_r.m4 serial 14
 dnl Copyright (C) 2002, 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -43,6 +43,7 @@
   dnl glibc >= 2.3.4 and cygwin 1.7.9 have a function __xpg_strerror_r.
+  AC_CHECK_FUNCS_ONCE([snprintf])
 # Detect if strerror_r works, but without affecting whether a replacement
In memoriam Martha Corey <http://en.wikipedia.org/wiki/Martha_Corey>

reply via email to

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