Patches to 3.2.3 for HP-UX 11.23/IA, SGI C++ compiler

Albert Chin kdevelop-devel at mlists.thewrittenword.com
Tue Jan 24 19:51:10 UTC 2006


On Tue, Jan 24, 2006 at 10:26:59AM +0300, Vladimir Prus wrote:
> I see why other strchr does cause problems. Thanks, the patch to 
> framestackwidget.cpp is now comitted, in revision 501878 
> on /branches/kdevelop/3.4/languages/cpp/debugger
> 
> > So, no bug in the compiler.
> 
> I'm afraid there is. The C standard gives the following prototype for strchr:
> 
>     char *strchr(const char *s, int c);
> 
> and:
> 
> 1. No prototype in your compiler matches the above.
> 2. I'm pretty sure C implementation is not allowed to add extra
>    overloads that change the meaning of programs.
> 
> I'd really suggest you report this as bug.

I looked at <string.h> on some of the systems and I don't think the
above is correct. From the Sun Solaris 10 <iso/string_iso.h>:
  /*
   * The C++ Standard (ISO/IEC 14882:1998) specifies that each of the
   * function signatures for the following functions be replaced by
   * two declarations, both of which have the same behavior.
   */
  #if __cplusplus >= 199711L
  ...
  #else /* __cplusplus >= 199711L */
  extern void *memchr(const void *, int, size_t);
  extern char *strchr(const char *, int);
  extern char *strpbrk(const char *, const char *);
  extern char *strrchr(const char *, int);
  extern char *strstr(const char *, const char *);
  #endif /* __cplusplus >= 199711L */

>From the HP-UX 11.23/IA <string.h>
  #if defined(__HP_NO_STRING_OVERLOADS) ||        \
     !(defined(_NAMESPACE_STD)          ||        \
       defined(__HPACC_STRICTER_ANSI__) ||        \
       defined(_HP_NAMESPACE_STD))
       extern char *strchr(const char *, int);
       extern char *strpbrk(const char *, const char *);
       extern char *strrchr(const char *, int);
       extern char *strstr(const char *, const char *);
  #else

>From the IRIX <internal/string_core.h>
  /*
   * In C++, five of the functions from the C string library are replaced
   * by overloaded pairs.  (Overloaded on const.)  In each case, there is
   * no semantic difference between the C function and the C++ functions.
   * We handle this by declaring the C version in an internal namespace;
   * each C++ version just turns around and calls the C version, performing
   * whatever const manipulations are necessary.  Note that this trick only
   * works because a namespace doesn't appear in the mangled name of an
   * extern "C" function.  Extern "C" names aren't mangled.
   */
  namespace __sgilib {
    extern "C" {
      extern void *memchr(const void *, int, size_t);
      extern char *strchr(const char *, int);
      extern char *strpbrk(const char *, const char *);
      extern char *strrchr(const char *, int);
      extern char *strstr(const char *, const char *);
    } /* Close extern "C" */
  } /* Close namespace __sgilib. */

In each of these cases, they explicitly do not define:
  extern char *strchr(const char *, int);

-- 
albert chin (china at thewrittenword.com)




More information about the KDevelop-devel mailing list