compiling on sparc-sun-sunos4.1.4 vs. solaris

Edward_C_Morgan ecmorgan@lucent.com
Thu Jan 7 09:14:00 GMT 1999


The following programs compiles ok on a solaris machine running egcs 1.1.1 (egcs-2.91.60)
but not on a sunos4.1.4 machine.

$ g++ -o jnk jnk.cc
ld: Undefined symbol 
   basic_string<char, string_char_traits<CharNoCase>, __default_alloc_template<0, 0> >::nilRep      
collect2: ld returned 2 exit status


It doesn't appear to instantiate the basic_string<char, string_char_traits<CharNoCase> >
template properly.




#include <string>
#include <ctype.h>

class CharNoCase { };

struct string_char_traits<CharNoCase> : public string_char_traits<char> {
  typedef char char_type;

  static bool eq (const char_type & c1, const char_type& c2)
    { return ( tolower(c1) == tolower(c2) ); }
  static bool ne (const char_type& c1, const char_type& c2)
    { return ( tolower(c1) != tolower(c2) ); }
  static bool lt (const char_type& c1, const char_type& c2)
    { return ( tolower(c1) < tolower(c2) ); }
  
  static int compare (const char_type* s1, const char_type* s2, size_t n);
};

int 
string_char_traits<CharNoCase>::compare(const char_type* s1, 
                const char_type* s2, size_t n)
{ 
        for(size_t i=0;i<n;i++,s1++,s2++) {
                char_type x=tolower(*s1);
                char_type y=tolower(*s2);
                if ( x != y ) {
                        return( x<y?-1:1);
                }
        }
        return(0);
}

typedef basic_string<char,string_char_traits<CharNoCase> > StringNoCase;

main()
{
        StringNoCase a;
        a="hello world";
        size_t i=a.find('o');
        return(0);
}

-- 
=========================================
 Edward C. Morgan
 Email:  ecmorgan@lucent.com
=========================================



More information about the Gcc-bugs mailing list