strnlen, strict ansi, newlib vs glibc

Luca Barbato
Sat Sep 13 12:58:00 GMT 2014

On 14/08/14 17:27, Joel Sherrill wrote:
> Hi
> I have some native C++ code that I developed on CentOS and it
> has no warnings. Someone moved it to Cygwin and reported warnings
> for strnlen() not being prototyped. I investigated and the program did
> include string.h. I tried RTEMS tools and got the same as Cygwin
> since we have the same string.h from newlib.
> Investigating this, it appears that strnlen() is protected by
> __STRICT_ANSI__ on newlib and  __USE_XOPEN2K8 on Linux.
> Command: g++ -Wall -std=c++0x -c
> This program is enough to reproduce the issue:
>     #include <string.h>
>     // size_t strnlen( const char *, size_t );
>     size_t f( const char *str )
>     {
>       return strnlen( str, 1000 );
>     }
> What do you all think?

Might be nice to add the support for _DEFAULT_SOURCE with the semantic
of not filter what is on by default notwithstanding the defines -std
might set.

It seems supported by glibc and musl so might be good to do as well.


More information about the Newlib mailing list