egcs 1.1a on DEC alpha OSF/3.2, problem with include files

kuball@zedo.fuedo.de kuball@zedo.fuedo.de
Wed Sep 9 04:04:00 GMT 1998


I'm having a problem with the prototypes of the functions strncmp and
bcopy. The c++ compiler does not see them, the c compiler does.
Consider the following code:

#include <string.h>
#include <fstream.h>

//extern "C" int strncmp( const char*, const char*, int );
//extern "C" void bcopy( const char*, char*, int );

int
main( int, char** )
{
  char buf[40];
  bcopy( "This is a small test", buf, 21 );
  cout << buf << endl;

  cout << "test ncmp: " << strncmp( "this", "that", 2 ) << endl;
  cout << "test cmp: " << strcmp( "this", "that" ) << endl;

  return( 0 );  
}

compiling the above program gives the following warnings:

>gcc test.cpp -lstdc++
test.cpp: In function `int main(int, char **)':
test.cpp:12: warning: implicit declaration of function `int bcopy(...)'
test.cpp:15: warning: implicit declaration of function `int strncmp(...)'
>

though the resulting program works. Uncomenting the prototypes solves
the problem. Well, I looked into the string.h include file from

 /usr/local/lib/gcc-lib/alpha-dec-osf3.2/egcs-2.91.57/include

but found no notable difference between the prototype for strcmp and
strncmp. So, why does it not work?


Martin Kuball






More information about the Gcc-bugs mailing list