[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: lack of wstring in libstdc++2.8-dev



On Fri, Oct 09, 1998 at 07:22:07PM -0700, Jeff McWilliams wrote:
> Hi,
> 
> I've got g++ 2.9.29-0.6, the egcs compiler, and libstdc++2.8dev
> 2.9.29-0.6 installed.  I was playing around with some STL stuff when I
> tried to declare a wstring.  No luck. 
> 
> Examining the file /usr/include/g++/string yields:
> 
> // Main header for the -*- C++ -*- string classes.
> 
> #ifndef __STRING__
> #define __STRING__
> 
> #include <std/bastring.h>
> 
> exter "C++" {
> typedef basic_string <char> string;
> // typedef basic_string <wchar_t> wstring;
> } // extern "C++"
> 
> #endif
> 
> 
> ##########
> Okay - so what's up - who commented out the typedef for wstring?
> Is this Debian specific or something related to gcc/egcs?
> I learned STL using Microsoft's compiler and I'm new to gcc/egcs 
> STL support.
> 
> Enquiring minds would like to know.
> I tried declaring a basic_string<wchar_t> in my own app and it blew up
> pretty badly.  
> 
> test.cpp:
> 
> #include <stdio.h>
> #include <string>
> 
> main()
>   {
>   basic_string<char> sString;
>   }
> 
> compiles okay, but adding 
> 
> basic_string{wchar_t} sString2
> 
> really causes it to blow up.  I'm using the following line to compile:
> 
> c++ -o test test.cpp
> 
> Also, shouldn't the above code require a "using namespace std" before
> main, or for me to use "std::basic_string<char> sString;"  ??
> 

The string class is best used as

#include <string>           // Make sure this is before any other #includes
                            // (due to a problem with g++2.7.x compiler

void main(void)
{
	string hello;
	string byebye;

	hello = "hello World";
	byebye = hello;
}


See http://www.sgi.com/Technology/STL for the current STL implementation.

(Also, why is your file .cpp?  Thats a preproccer produced file - shouldn't
you use .cc?)

Chris


-- 

----------------------------------------------------------------------
REALITY.SYS corrupted: Reboot universe? (Y/N/Q)   ....Debian GNU/Linux
----------------------------------------------------------------------
Reply with subject 'request key' for PGP public key.  KeyID 0xA9E087D5

Attachment: pgpoOLtt5wwQC.pgp
Description: PGP signature


Reply to: