bug-gnu-utils
[Top][All Lists]
Advanced

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

sharutils: compilation failure with Sun C on Linux


From: Bruno Haible
Subject: sharutils: compilation failure with Sun C on Linux
Date: Wed, 10 May 2006 22:08:02 +0200
User-agent: KMail/1.5

Hi,

When compiling sharutils-4.6.1 with SunPRO C 5.9 on Linux/x86 with glibc-2.3.x,
the following compilation error occurs:

/opt/sun/compilers-20060314/bin/c89 -Xa 
-DLOCALEDIR=\"/packages/inst-sunpro/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. 
 -I. -I.. -I../lib -I../intl -I/packages/inst-sunpro/include  -xO5 -c shar.c
"shar.c", line 141: identifier redeclared: readdir64
        current : function() returning pointer to struct dirent {unsigned long 
long d_ino, long long d_off, unsigned short d_reclen, unsigned char d_type, 
array[256] of char d_name}
        previous: function(pointer to struct __dirstream {}) returning pointer 
to struct dirent64 {unsigned long long d_ino, long long d_off, unsigned short 
d_reclen, unsigned char d_type, array[256] of char d_name} : 
"/usr/include/dirent.h", line 166
c89: acomp failed for shar.c
make[2]: *** [shar.o] Fehler 2

What's happening is that
  1) autoconfiguration chooses to use the LFS extensions
     (#define _FILE_OFFSET_BITS 64 in config.h),
  2) glibc's <bits/dirent.h> does this:

struct dirent
  {
    __ino64_t d_ino;
    __off64_t d_off;
    unsigned short int d_reclen;
    unsigned char d_type;
    char d_name[256];           /* We must not include limits.h! */
  };
struct dirent64
  {
    __ino64_t d_ino;
    __off64_t d_off;
    unsigned short int d_reclen;
    unsigned char d_type;
    char d_name[256];           /* We must not include limits.h! */
  };

  3) glibc's <dirent.h> does this:

# ifdef __REDIRECT
extern struct dirent *__REDIRECT (readdir, (DIR *__dirp), readdir64)
     __nonnull ((1));
# else
#  define readdir readdir64
# endif

1) is good; the LFS API should be used when the platform supports it.
2) is suboptimal, but there is no way in C to define a struct type under
   two names, except for "#define dirent64 dirent" or "#define dirent64 dirent",
   but these are unacceptable to the glibc maintainer,
3) is also suboptimal, but AFAIK there is no way to define the __REDIRECT
   macro for this compiler.

The result is that  readdir()  is defined to a be a function that returns
a 'struct dirent64 *' rather than a 'struct dirent *'; these two types are
equivalent but not the same types, and the redeclation of readdir() gives a
compilation error.

The safe fix is to omit the declaration when readdir is a macro (because in
this case something fishy is going on in the system header files). A warning
then appears at the use of readdir(), but at least it compiles and works.


*** sharutils-4.6.1/src/shar.c.bak      2005-11-19 02:35:25.000000000 +0100
--- sharutils-4.6.1/src/shar.c  2006-05-07 02:49:29.000000000 +0200
***************
*** 138,144 ****
--- 138,146 ----
  #endif
  
  DIR *opendir ();
+ #ifndef readdir
  struct dirent *readdir ();
+ #endif
  
  #endif /* !NO_WALKTREE */
   





reply via email to

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