🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42705

gcc-2.7.0 string probs on sunos

#42705
From: Peter Weiss
Date: Fri, 10 Nov 1995 00:00
136 lines
4713 bytes
Hello world,

    I'm  porting some   software   from linux   (gcc-2.7.0) to   sunos  4.1.3
    (gcc-2.7.0) and since it will be published under the GPL,  I'd like it in
    detail, how to  patch the following problim with   the standard C  string
    library functions:

    In a C++ file the strcat()  function is not  know and I have currently to
    define it as follows:

File UnitAtom.h:

#include <string.h>    // includes the c++ header
                       //  /home/gnu/lib/g++-include/std/cstring.h

// Peter's strcat() prototype patch:
#ifdef sun

extern "C" char *strcat(char *s1, char *s2);
inline char *
strcat(const char *s1, const char *s2)
{
  return (char *) strcat((char *) s1, (char *) s2);
}

#endif

// Rest of the file deleted

--------------------------------------------------------------------------------
    The standard C file

    /home/gnu/lib/gcc-lib/sparc-sun-sunos4.1.3C/2.7.0/include/string.h of gcc

    contains the following:


#ifndef __string_h
#ifndef _PARAMS
#if defined(__STDC__) || defined(__cplusplus)
#define _PARAMS(ARGS) ARGS
#else
#define _PARAMS(ARGS) ()
#endif
#endif /* _PARAMS */
#define __string_h

extern char *   strcat _PARAMS((char *, const char *));
extern char *   strchr _PARAMS((const char *, int));
extern int      strcmp _PARAMS((const char *, const char *));
extern char *   strcpy _PARAMS((char *, const char *));
extern size_t   strcspn _PARAMS((const char *, const char *));
#ifndef _POSIX_SOURCE
extern char *   strdup _PARAMS((const char *));
#endif
extern size_t   strlen _PARAMS((const char *));
extern char *   strncat _PARAMS((char *, const char *, __SIZE_TYPE__ ));
extern int      strncmp _PARAMS((const char *, const char *, __SIZE_TYPE__ ));
extern char *   strncpy _PARAMS((char *, const char *, __SIZE_TYPE__ ));
extern char *   strpbrk _PARAMS((const char *, const char *));
extern char *   strrchr _PARAMS((const char *, int));
extern size_t   strspn _PARAMS((const char *, const char *));
extern char *   strstr _PARAMS((const char *, const char *));
extern char *   strtok _PARAMS((char *, const char *));

    So I think the _PARAMS macro is __cplusplus prepared and should work if I
    would be able to include it.

--------------------------------------------------------------------------------
    The default included C++ header file string.h looks something like this:

    (It  includes at  least /home/gnu/lib/g++-include/std/cstring.h, which is
    mentioned here)

// The -*- C++ -*- null-terminated string header.
// This file is part of the GNU ANSI C++ Library.

#ifndef __CSTRING__
#define __CSTRING__

// The ANSI C prototypes for these functions have a const argument type and
// non-const return type, so we can't use them.

#define strchr  __hide_strchr
#define strpbrk __hide_strpbrk
#define strrchr __hide_strrchr
#define strstr  __hide_strstr
#define memchr  __hide_memchr

#include_next <string.h>

#undef strchr
#undef strpbrk
#undef strrchr
#undef strstr
#undef memchr

#include <std/cstddef.h>

#ifdef __GNUG__
#pragma interface "std/cstring.h"
#endif

extern "C" const char *strchr (const char *, int);
inline char *
strchr (char *s, int c)
{
  return (char*) strchr ((const char *) s, c);
}


#endif
--------------------------------------------------------------------------------

    There are most of the standard C strfunctions declared to work with C++,
    but not all, why?

    Any hints, what I should do?

    How am I able to tell gcc to include the standard string.h file when
    compiling in C++-mode?

    Patching all function definitions the way above, I think is not the best
    way.

--

Peter

--------------------------------------------------------------------------------
Peter Weiss               email: Peter.Weiss@informatik.uni-oldenburg.de
Sonnenstra�e 17         WWW-URL: http://www.informatik.uni-oldenburg.de:/~weissp
D-26123 Oldenburg           Tel:  0441/ 81058
--------------------------------------------------------------------------------
--- Slow has got 4 letters so has calm; speed has got 5 letters so has death ---
--------------------------------------------------------------------------------
Technical Details
Message-ID: <47vjpt$rib@news.Informatik.Uni-Oldenburg.DE>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 11318c,5be68e53a6e32bfe,start
X-Google-Attributes: gid11318c,public
From: Peter.Weiss@Informatik.Uni-Oldenburg.DE (Peter Weiss)
Subject: gcc-2.7.0 string probs on sunos
Date: 1995/11/10
Message-ID: <47vjpt$rib@news.Informatik.Uni-Oldenburg.DE>
X-Deja-AN: 119086016
distribution: world
organization: University of Oldenburg, Germany
newsgroups: gnu.gcc.help