<p dir="ltr">I assume the code in question has a "using namespace std;"?</p>
<p dir="ltr">I don't see any way around this other than giving up on trying to fix the function signatures here (or maybe adding a Clang feature to let us fix the bad signature).</p>
<div class="gmail_quote">On Oct 15, 2015 11:07 AM, "Manman Ren via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Richard,<br>
<br>
This is causing a failure when building povray on iOS.<br>
<br>
Compilation error:<br>
/Users/buildslave/tmp/test-suite-externals/speccpu2006/benchspec/CPU2006/453.povray/src/fileinputoutput.cpp:364:20: error: call to 'strrchr' is ambiguous<br>
     const char *p=strrchr(name, '.’);<br>
<br>
iOS.sdk/usr/include/string.h:87:7: note: candidate function<br>
char    *strrchr(const char *, int);<br>
         ^<br>
/Users/buildslave/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:109:46: note: candidate function<br>
inline _LIBCPP_INLINE_VISIBILITY const char* strrchr(const char* __s, int __c) {return ::strrchr(__s, __c);}<br>
<br>
It is a little strange to have "char    *strrchr(const char *, int);” in iOS. But it is already in our SDK.<br>
<br>
Do you have any suggestion on how to fix this?<br>
<br>
Thanks,<br>
Manman<br>
<br>
> On Oct 9, 2015, at 6:25 PM, Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: rsmith<br>
> Date: Fri Oct  9 20:25:31 2015<br>
> New Revision: 249929<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=249929&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=249929&view=rev</a><br>
> Log:<br>
> Split <string.h> out of <cstring>.<br>
><br>
> Also fix the overload set for the five functions whose signatures change in the<br>
> case where we can fix it. This is already covered by existing tests for the<br>
> affected systems.<br>
><br>
> Added:<br>
>    libcxx/trunk/include/string.h<br>
>      - copied, changed from r249736, libcxx/trunk/include/cstring<br>
> Modified:<br>
>    libcxx/trunk/include/cstring<br>
><br>
> Modified: libcxx/trunk/include/cstring<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstring?rev=249929&r1=249928&r2=249929&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstring?rev=249929&r1=249928&r2=249929&view=diff</a><br>
> ==============================================================================<br>
> --- libcxx/trunk/include/cstring (original)<br>
> +++ libcxx/trunk/include/cstring Fri Oct  9 20:25:31 2015<br>
> @@ -78,37 +78,42 @@ using ::strcmp;<br>
> using ::strncmp;<br>
> using ::strcoll;<br>
> using ::strxfrm;<br>
> +using ::strcspn;<br>
> +using ::strspn;<br>
> +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS<br>
> +using ::strtok;<br>
> +#endif<br>
> +using ::memset;<br>
> +using ::strerror;<br>
> +using ::strlen;<br>
><br>
> -using ::memchr;<br>
> +// MSVCRT, GNU libc and its derivates already have the correct prototype in<br>
> +// <string.h> if __cplusplus is defined. This macro can be defined by users if<br>
> +// their C library provides the right signature.<br>
> +#if defined(__GLIBC__) || defined(_LIBCPP_MSVCRT) || defined(__sun__) || \<br>
> +    defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)<br>
> +#define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS<br>
> +#endif<br>
><br>
> +#ifdef _LIBCPP_STRING_H_HAS_CONST_OVERLOADS<br>
> using ::strchr;<br>
> -<br>
> -using ::strcspn;<br>
> -<br>
> using ::strpbrk;<br>
> -<br>
> using ::strrchr;<br>
> -<br>
> -using ::strspn;<br>
> -<br>
> +using ::memchr;<br>
> using ::strstr;<br>
> -<br>
> -// MSVCRT, GNU libc and its derivates already have the correct prototype in <string.h> #ifdef __cplusplus<br>
> -#if !defined(__GLIBC__) && !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)<br>
> +#else<br>
> +inline _LIBCPP_INLINE_VISIBILITY const char* strchr(const char* __s, int __c) {return ::strchr(__s, __c);}<br>
> inline _LIBCPP_INLINE_VISIBILITY       char* strchr(      char* __s, int __c) {return ::strchr(__s, __c);}<br>
> +inline _LIBCPP_INLINE_VISIBILITY const char* strpbrk(const char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);}<br>
> inline _LIBCPP_INLINE_VISIBILITY       char* strpbrk(      char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);}<br>
> +inline _LIBCPP_INLINE_VISIBILITY const char* strrchr(const char* __s, int __c) {return ::strrchr(__s, __c);}<br>
> inline _LIBCPP_INLINE_VISIBILITY       char* strrchr(      char* __s, int __c) {return ::strrchr(__s, __c);}<br>
> +inline _LIBCPP_INLINE_VISIBILITY const void* memchr(const void* __s, int __c, size_t __n) {return ::memchr(__s, __c, __n);}<br>
> inline _LIBCPP_INLINE_VISIBILITY       void* memchr(      void* __s, int __c, size_t __n) {return ::memchr(__s, __c, __n);}<br>
> +inline _LIBCPP_INLINE_VISIBILITY const char* strstr(const char* __s1, const char* __s2) {return ::strstr(__s1, __s2);}<br>
> inline _LIBCPP_INLINE_VISIBILITY       char* strstr(      char* __s1, const char* __s2) {return ::strstr(__s1, __s2);}<br>
> #endif<br>
><br>
> -#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS<br>
> -using ::strtok;<br>
> -#endif<br>
> -using ::memset;<br>
> -using ::strerror;<br>
> -using ::strlen;<br>
> -<br>
> _LIBCPP_END_NAMESPACE_STD<br>
><br>
> #endif  // _LIBCPP_CSTRING<br>
><br>
> Copied: libcxx/trunk/include/string.h (from r249736, libcxx/trunk/include/cstring)<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string.h?p2=libcxx/trunk/include/string.h&p1=libcxx/trunk/include/cstring&r1=249736&r2=249929&rev=249929&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string.h?p2=libcxx/trunk/include/string.h&p1=libcxx/trunk/include/cstring&r1=249736&r2=249929&rev=249929&view=diff</a><br>
> ==============================================================================<br>
> --- libcxx/trunk/include/cstring (original)<br>
> +++ libcxx/trunk/include/string.h Fri Oct  9 20:25:31 2015<br>
> @@ -1,5 +1,5 @@<br>
> // -*- C++ -*-<br>
> -//===--------------------------- cstring ----------------------------------===//<br>
> +//===--------------------------- string.h ---------------------------------===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -8,19 +8,16 @@<br>
> //<br>
> //===----------------------------------------------------------------------===//<br>
><br>
> -#ifndef _LIBCPP_CSTRING<br>
> -#define _LIBCPP_CSTRING<br>
> +#ifndef _LIBCPP_STRING_H<br>
> +#define _LIBCPP_STRING_H<br>
><br>
> /*<br>
> -    cstring synopsis<br>
> +    string.h synopsis<br>
><br>
> Macros:<br>
><br>
>     NULL<br>
><br>
> -namespace std<br>
> -{<br>
> -<br>
> Types:<br>
><br>
>     size_t<br>
> @@ -53,62 +50,14 @@ void* memset(void* s, int c, size_t n);<br>
> char* strerror(int errnum);<br>
> size_t strlen(const char* s);<br>
><br>
> -}  // std<br>
> -<br>
> */<br>
><br>
> #include <__config><br>
> -#include <string.h><br>
><br>
> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)<br>
> #pragma GCC system_header<br>
> #endif<br>
><br>
> -_LIBCPP_BEGIN_NAMESPACE_STD<br>
> -<br>
> -using ::size_t;<br>
> -using ::memcpy;<br>
> -using ::memmove;<br>
> -using ::strcpy;<br>
> -using ::strncpy;<br>
> -using ::strcat;<br>
> -using ::strncat;<br>
> -using ::memcmp;<br>
> -using ::strcmp;<br>
> -using ::strncmp;<br>
> -using ::strcoll;<br>
> -using ::strxfrm;<br>
> -<br>
> -using ::memchr;<br>
> -<br>
> -using ::strchr;<br>
> -<br>
> -using ::strcspn;<br>
> -<br>
> -using ::strpbrk;<br>
> -<br>
> -using ::strrchr;<br>
> -<br>
> -using ::strspn;<br>
> -<br>
> -using ::strstr;<br>
> -<br>
> -// MSVCRT, GNU libc and its derivates already have the correct prototype in <string.h> #ifdef __cplusplus<br>
> -#if !defined(__GLIBC__) && !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)<br>
> -inline _LIBCPP_INLINE_VISIBILITY       char* strchr(      char* __s, int __c) {return ::strchr(__s, __c);}<br>
> -inline _LIBCPP_INLINE_VISIBILITY       char* strpbrk(      char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);}<br>
> -inline _LIBCPP_INLINE_VISIBILITY       char* strrchr(      char* __s, int __c) {return ::strrchr(__s, __c);}<br>
> -inline _LIBCPP_INLINE_VISIBILITY       void* memchr(      void* __s, int __c, size_t __n) {return ::memchr(__s, __c, __n);}<br>
> -inline _LIBCPP_INLINE_VISIBILITY       char* strstr(      char* __s1, const char* __s2) {return ::strstr(__s1, __s2);}<br>
> -#endif<br>
> -<br>
> -#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS<br>
> -using ::strtok;<br>
> -#endif<br>
> -using ::memset;<br>
> -using ::strerror;<br>
> -using ::strlen;<br>
> -<br>
> -_LIBCPP_END_NAMESPACE_STD<br>
> +#include_next <string.h><br>
><br>
> -#endif  // _LIBCPP_CSTRING<br>
> +#endif  // _LIBCPP_STRING_H<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>