clang copy of limits.h misses NAME_MAX

Marco Atzeri marco.atzeri@gmail.com
Thu Mar 17 13:35:00 GMT 2016



On 17/03/2016 14:19, Ismail Donmez wrote:
> Hi,
>
> On Thu, Mar 17, 2016 at 3:11 PM, Hans-Bernhard Bröker
> <HBBroeker@t-online.de> 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)
>> {
>>          return;
>> }
>>
>> $ 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
>> 'NAME_MAX'
>>    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
>> libclang3.7-3.7.1-1
>
> clangs limits.h has:
>
> #if __STDC_HOSTED__ && __has_include_next(<limits.h>)
> #include_next <limits.h>
> #endif
>
> 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.
>
> ismail
>

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:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list