This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Severe problems with the cstring functions (new and again)

The problems with the cstring functions related to the recent change
of the bits/std_cstring.h show up again:

I can no longer compile td.C. This is the source code of the original bug
report, PR 2767, which I could compile about a week ago. Therefore,
some change in the last week in the gcc or libstdc++ sources broke the
compilation of this code snippet again.   

source code td.C
using namespace std;

void f(const char *name)
g++ -v td.C
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77,objc
Thread model: posix
gcc version 3.0 20010604 (prerelease)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ td.C -D__GNUG__=3 -D_GNU_SOURCE -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase td.C -version -o /tmp/cc1nJEvi.s
GNU CPP version 3.0 20010604 (prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0 20010604 (prerelease) (i686-pc-linux-gnu)
	compiled by GNU C version 3.0 20010604 (prerelease).
#include "..." search starts here:
#include <...> search starts here:
End of search list.
td.C: In function `void f(const char*)':
td.C:7: call of overloaded `strchr(const char*&, char)' is ambiguous
/usr/include/string.h:155: candidates are: char* strchr(const char*, int)
/usr/local/include/g++-v3/bits/std_cstring.h:147:                 char* 
   std::strchr(char*, int) <near match>
/usr/local/include/g++-v3/bits/std_cstring.h:143:                 const char* 
   std::strchr(const char*, int)

Compiling the following codes does not work either, the cstring
functions in the global namespace are not visible; this breaks a lot
of code. 

source code t.C
#include <fstream>
#include <string.h>

void f(const char *buff)
    if (strcmp(buff,"//vbm") != 0) { }

g++ -c t.C
t.C: In function `void f(const char*)':
t.C:6: `strcmp' undeclared (first use this function)
t.C:6: (Each undeclared identifier is reported only once for each function it 
   appears in.)

source code tc.C
#include <iostream>
#include <string.h>   

void f(const char *s)
    char *cp = new char[strlen(s) + 1];
    strcpy(cp, s);

g++ -c tc.C
tc.C: In function `void f(const char*)':
tc.C:6: `strlen' undeclared (first use this function)
tc.C:6: (Each undeclared identifier is reported only once for each function it 
   appears in.)
tc.C:7: `strcpy' undeclared (first use this function)

source code tm.C
#include <string>
extern "C"{
#include <string.h>
int streamStringOut(char*& s){
  int len;
  int nBytes= memcpy((void*)s,(const void*)&len, sizeof(len));;
  return nBytes;

g++ -c tm.C
tm.C: In function `int streamStringOut(char*&)':
tm.C:7: `memcpy' undeclared (first use this function)
tm.C:7: (Each undeclared identifier is reported only once for each function it 
   appears in.)

The code snippets are from boost, root and my code repositories. To
work around this problem you have to change hundred lines of code for
root for example. Please fix this problem. If that is not possible in
a short time, then please revert the changes to the std_cstring.h

Hope this helps,

Peter Schmid  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]