From: Jan Nieuwenhuizen Without this patch, libguile exports symbols such as opendir, readdir, which expect and use guile's struct dirent that differs from mingw's dirent. Linking to libguile when using mingw's dirent gives unexpected results. 2011-02-15 Jan Nieuwenhuizen * libguile/win32-dirent.c: * libguile/filesys.c [MINGW32]: Include win32-dirent.h early, to pick-up defines. * libguile/win32-dirent.h (opendir, readdir, closedir, rewinddir, seekdir, telldir, dirfd): #define to guile_opendir ect. --- libguile/filesys.c | 5 ++++- libguile/win32-dirent.c | 4 ++-- libguile/win32-dirent.h | 8 ++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/libguile/filesys.c b/libguile/filesys.c index 93b0ce2..880ee86 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -35,6 +35,10 @@ #include #include +#if defined (__MINGW32__) || defined (_MSC_VER) || defined (__BORLANDC__) +# include "win32-dirent.h" +#endif /* __MINGW32__ || _MSC_VER || __BORLANDC__ */ + #include "libguile/_scm.h" #include "libguile/smob.h" #include "libguile/feature.h" @@ -94,7 +98,6 @@ #if defined (__MINGW32__) || defined (_MSC_VER) || defined (__BORLANDC__) -# include "win32-dirent.h" # define NAMLEN(dirent) strlen((dirent)->d_name) /* The following bits are per AC_HEADER_DIRENT doco in the autoconf manual */ #elif HAVE_DIRENT_H diff --git a/libguile/win32-dirent.c b/libguile/win32-dirent.c index de170c7..b5b2c60 100644 --- a/libguile/win32-dirent.c +++ b/libguile/win32-dirent.c @@ -20,14 +20,14 @@ # include #endif +#include "win32-dirent.h" + #include "libguile/__scm.h" #include #include #include -#include "win32-dirent.h" - DIR * opendir (const char * name) { diff --git a/libguile/win32-dirent.h b/libguile/win32-dirent.h index 578db49..f9f8fe9 100644 --- a/libguile/win32-dirent.h +++ b/libguile/win32-dirent.h @@ -27,6 +27,14 @@ #include +#define opendir guile_opendir +#define readdir guile_readdir +#define closedir guile_closedir +#define rewinddir guile_rewinddir +#define seekdir guile_seekdir +#define telldir guile_telldir +#define dirfd guile_dirfd + struct dirstream { int fd; /* File descriptor. */ -- 1.7.1 -- Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.nl