This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: clang copy of limits.h misses NAME_MAX

On 17/03/2016 14:19, Ismail Donmez wrote:

On Thu, Mar 17, 2016 at 3:11 PM, Hans-Bernhard BrÃker
<> wrote:
Hello there,

clang has its own copy of some system headers.  One of those lacks an entry
that breaks compilation of any program trying to work with directories the
POSIX way:

$ cat tdirent.c
#include <dirent.h>

void foo(void)

$ clang -c tdirent.c
In file included from tdirent.c:1:
In file included from /usr/include/dirent.h:6:
/usr/include/sys/dirent.h:31:15: error: use of undeclared identifier
   char d_name[NAME_MAX + 1];
1 error generated.

The same file compiles just fine with GCC.  The problem turns out to be that
NAME_MAX is defined in <limits.h> as seen by GCC, but not in the same header
read by clang.  The culprit is this file:

$ cygcheck -f /usr/lib/clang/3.7.1/include/limits.h

clangs limits.h has:

#if __STDC_HOSTED__ && __has_include_next(<limits.h>)
#include_next <limits.h>

So it does depend on system's own limits.h which should have this
definition. And cygwin's /usr/include/limits.h does have NAME_MAX
defined but show its being hidden. Checking the preprocessed source
file might help to see why.


it seems to prefer gcc headers

# 1 "/usr/bin/../lib/clang/3.7.1/include/limits.h" 1 3 4
# 37 "/usr/bin/../lib/clang/3.7.1/include/limits.h" 3 4
# 1 "/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/include/limits.h" 1 3 4
# 38 "/usr/bin/../lib/clang/3.7.1/include/limits.h" 2 3 4
# 17 "/usr/include/sys/dirent.h" 2 3 4

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]