X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: pavenis AT lanet DOT lv To: Hayden Muhl , djgpp AT delorie DOT com Date: Thu, 7 Feb 2002 18:15:28 +0200 MIME-Version: 1.0 Subject: Re: Using strings in DJGPP Message-ID: <3C62C440.13600.1DE0D1F@localhost> In-reply-to: <200202071335.HAA24357@mailhub-1.iastate.edu> X-mailer: Pegasus Mail for Windows (v4.01) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 7 Feb 2002 at 7:35, Hayden Muhl wrote: > I don't get this. I have been trying to get DJGPP to work, but it does not > like strings at all. Here is my program. > > #include > #include > #include > > int main() > { > string a = "Yo"; > cout << a; > return 0; > } > > and here is the error I get. > > search.cpp: In function `int main()': > search.cpp:7: `string' undeclared (first use this function) > search.cpp:7: (Each undeclared identifier is reported only once for each > function it appears in.) > search.cpp:7: parse error before `=' token > search.cpp:8: `a' undeclared (first use this function) Of course it's so with gcc-3.X as string now is in std namespace. So use std::string instead of string or put 'using namespace std;' earlier > I have tried changing the line #include to a ton of different stuff, > but nothing works. Here's a list of SOME of the the stuff I have tried. > > #include > #include > #include <_String.h> _String.h is from libg++. It DOES NOT work with gcc-3.X and perhaps never will. libg++ is dead and it's use is discouraged > #include > #include > > I don't get it. Did I get a bad version of the compiler? Other header files > work fine. iostream and fstream work beautifully, but not string. I just > don't get it. > Maybe iostream and fstream classes work if You include iostream.h and fstream.h which is also obsolete and will soon be deprecated (Expect to get warning about that when gcc-3.1 will be released). One should use #include #include etc. instead. Note that You'll get all classes in std namespace Andris