public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
* Broken header dirent.h
@ 2014-07-12 17:54 Ryan Johnson
  2014-07-14  8:49 ` Corinna Vinschen
  0 siblings, 1 reply; 3+ messages in thread
From: Ryan Johnson @ 2014-07-12 17:54 UTC (permalink / raw)
  To: cygwin-developers

[-- Attachment #1: Type: text/plain, Size: 289 bytes --]

Hi all,

Please CC me in replies, I'm no longer a list member.

I recently tried to use <sys/dirent.h> in a C++ program and got linker 
errors. Turns out the header is neither C++-aware (extern "C") nor 
cygwin-aware (_EXFUN).

The attached patch fixes the problem for me.

Regards,
Ryan


[-- Attachment #2: dirent.h.patch --]
[-- Type: text/plain, Size: 2154 bytes --]

--- dirent.h.orig	2014-05-23 04:36:40.000000000 -0400
+++ dirent.h	2014-07-12 12:31:44.904628400 -0400
@@ -15,6 +15,10 @@
 #include <sys/types.h>
 #include <limits.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define __DIRENT_VERSION	2
 
 #ifndef __x86_64__
@@ -62,32 +66,32 @@
 #pragma pack(pop)
 #endif
 
-DIR *opendir (const char *);
-DIR *fdopendir (int);
-struct dirent *readdir (DIR *);
-int readdir_r (DIR * __restrict, struct dirent * __restrict,
-	       struct dirent ** __restrict);
-void rewinddir (DIR *);
-int closedir (DIR *);
+DIR *_EXFUN(opendir, (const char *));
+DIR *_EXFUN(fdopendir, (int));
+struct dirent *_EXFUN(readdir, (DIR *));
+int _EXFUN(readdir_r, (DIR * __restrict, struct dirent * __restrict,
+		       struct dirent ** __restrict));
+void _EXFUN(rewinddir, (DIR *));
+int _EXFUN(closedir, (DIR *));
 
-int dirfd (DIR *);
+int _EXFUN(dirfd, (DIR *));
 
 #ifndef _POSIX_SOURCE
 #ifndef __INSIDE_CYGWIN__
-long telldir (DIR *);
-void seekdir (DIR *, long loc);
+long _EXFUN(telldir, (DIR *));
+void _EXFUN(seekdir, (DIR *, long loc));
 #endif
 
-int scandir (const char *__dir,
+int _EXFUN(scandir, (const char *__dir,
 	     struct dirent ***__namelist,
 	     int (*select) (const struct dirent *),
-	     int (*compar) (const struct dirent **, const struct dirent **));
+	     int (*compar) (const struct dirent **, const struct dirent **)));
 
-int scandirat (int __dirfd, const char *__dir, struct dirent ***__namelist,
+int _EXFUN(scandirat, (int __dirfd, const char *__dir, struct dirent ***__namelist,
 	       int (*select) (const struct dirent *),
-	       int (*compar) (const struct dirent **, const struct dirent **));
+	       int (*compar) (const struct dirent **, const struct dirent **)));
 
-int alphasort (const struct dirent **__a, const struct dirent **__b);
+int _EXFUN(alphasort, (const struct dirent **__a, const struct dirent **__b));
 #ifdef _DIRENT_HAVE_D_TYPE
 /* File types for `d_type'.  */
 enum
@@ -117,4 +121,8 @@
 # define DTTOIF(dirtype)        ((dirtype) << 12)
 #endif /* _DIRENT_HAVE_D_TYPE */
 #endif /* _POSIX_SOURCE */
+
+#ifdef __cplusplus
+}
+#endif
 #endif /*_SYS_DIRENT_H*/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-14 14:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-12 17:54 Broken header dirent.h Ryan Johnson
2014-07-14  8:49 ` Corinna Vinschen
2014-07-14 14:51   ` Ryan Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).