Discussion:
Broken header dirent.h
Ryan Johnson
2014-07-12 17:53:39 UTC
Permalink
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
Corinna Vinschen
2014-07-14 08:49:02 UTC
Permalink
Hi Ryan,
Post by Ryan Johnson
Hi all,
Please CC me in replies, I'm no longer a list member.
Given the massive amount of mail on this list I can see your point... ;)
Post by Ryan Johnson
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).
It doesn't have to be. Including <sys/dirent.h> is not meant to be done
in application code. The POSIX header is <dirent.h>, not <sys/dirent.h>:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dirent.h.html

If you include <dirent.h>, your linker problems should go away.


Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
Ryan Johnson
2014-07-14 14:51:04 UTC
Permalink
Post by Corinna Vinschen
Hi Ryan,
Post by Ryan Johnson
Hi all,
Please CC me in replies, I'm no longer a list member.
Given the massive amount of mail on this list I can see your point... ;)
Actually, I do seem to be a list member of this list after all. It's the
main cygwin list that had too much traffic.
Post by Corinna Vinschen
Post by Ryan Johnson
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).
It doesn't have to be. Including <sys/dirent.h> is not meant to be done
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dirent.h.html
If you include <dirent.h>, your linker problems should go away.
Oops... I must have misread a man page somewhere. Could have sworn it
said to use sys/dirent.h, but die.net (my usual go-to for man pages
since I can't figure out how to install them locally) definitely agrees
with you.

Thanks,
Ryan

Loading...