[Top][All Lists]

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

scandir: portability fix

From: Bruno Haible
Subject: scandir: portability fix
Date: Sat, 20 Mar 2010 00:20:23 +0100
User-agent: KMail/1.9.9

On Solaris 8, I get this link error:

  CC -O    -L/home/haible/prefix-x86/lib  -o test-dirent-c++ test-dirent-c++.o 
../gllib/libgnu.a /home/haible/prefix-x86/lib/libintl.so -lc 
-R/home/haible/prefix-x86/lib -lm   -lm     -lm    -lm  -lm  -lm 
  Undefined                     first referenced
   symbol                           in file
  _D_ALLOC_NAMLEN                     ../gllib/libgnu.a(scandir.o)
  ld: fatal: Symbol referencing errors. No output written to test-dirent-c++
  *** Error code 1

The reason is that scandir.c uses _D_ALLOC_NAMLEN, which is a glibc specific
macro. This fixes it:

2010-03-19  Bruno Haible  <address@hidden>

        scandir: Fix link error on Solaris 8.
        * lib/scandir.c (_D_EXACT_NAMLEN, _D_ALLOC_NAMLEN): New fallback

--- lib/scandir.c.orig  Sat Mar 20 00:14:04 2010
+++ lib/scandir.c       Sat Mar 20 00:09:49 2010
@@ -33,6 +33,13 @@
 #undef select
+#ifndef _D_EXACT_NAMLEN
+# define _D_EXACT_NAMLEN(d) strlen ((d)->d_name)
+#ifndef _D_ALLOC_NAMLEN
+# define _D_ALLOC_NAMLEN(d) (_D_EXACT_NAMLEN (d) + 1)
 #if _LIBC
 # ifndef SCANDIR
 #  define SCANDIR scandir

reply via email to

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