delorie.com/archives/browse.cgi | search |
From: | "Tanes Sriviroolchai" <Tanes DOT Sriviroolchai AT Thailand DOT NCR DOT COM> |
Newsgroups: | comp.os.msdos.djgpp |
References: | <3aba8686_2 AT news4 DOT newsfeeds DOT com> |
Subject: | Re: DJGPP and the C++ standard |
Date: | Fri, 23 Mar 2001 15:11:16 +0700 |
Lines: | 130 |
X-Priority: | 3 |
X-MSMail-Priority: | Normal |
X-Newsreader: | Microsoft Outlook Express 5.50.4133.2400 |
X-MimeOLE: | Produced By Microsoft MimeOLE V5.50.4133.2400 |
X-Original-NNTP-Posting-Host: | nthbkk02.thailand.ncr.com |
Message-ID: | <3abb0524@rpc1284.daytonoh.ncr.com> |
X-Original-Trace: | 23 Mar 2001 03:11:16 -0500, nthbkk02.thailand.ncr.com |
NNTP-Posting-Host: | ncrnews.daytonoh.ncr.com |
X-Trace: | 23 Mar 2001 03:11:18 -0500, ncrnews.daytonoh.ncr.com |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
The libstdc++ comes with gcc 2.95.2 is not yet ISO C++ Compliant. I've ported STLport-4.0 to DJGPP and I've tested your program with STLport-4.0. It is ok. You can find DJGPP port of STLport-4.0 (source no binary, sorry) in ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/stlp40s.zip. However, size of executable when using stlp40s instead of libstdc++ will be bigger. You may need to prepare to sacrifice. Regards, Tanes Sriviroolchai "23yrold3yrold" <cbarry AT pangea DOT ca> wrote in message news:3aba8686_2 AT news4 DOT newsfeeds DOT com... > Short and simple; here's the code. At compile time, I get the error at the > bottom. I posted this at comp.lang.c++ for help, and everyone compiled it > just fine. So I'm gonna guess it's a DJGPP thing. Perhaps I have an outdated > version of the compiler's STL or something (my copy of DJGPP was downloaded > from the official homepage less than a year ago though). This is an example > program from "The C++ Standard Library" by Nicolai Josuttis (p. 603), if you > care. > > // io/sum1a.cpp > > #include <istream> > > namespace MyLib > { > double ReadAndProcessSum(std::istream& strm) > { > using std::ios; > double value, sum; > > // save current state of exception flags > ios::iostate oldExceptions = strm.exceptions(); > > // let failbit and badbit throw exceptions > // - NOTE: failbit is also set at end-of-file > strm.exceptions(ios::failbit | ios::badbit); > > try > { > // while stream is OK read value and add it to sum > sum = 0; > while (strm >> value) > { > sum += value; > } > } > > catch( ... ) > { > // if exception not caused by end-of-file > // - restore old state of exception flags > // - rethrow exception > if (!strm.eof()) > { > strm.exceptions(oldExceptions); // restore exception flags > throw; // rethrow > } > } > > // restore old state of exception flags > strm.exceptions(oldExceptions); > > // return sum > return sum; > } > } > > That file compiles fine ....... > > // io/summain.cpp > > #include <iostream> > #include <cstdlib> > > namespace MyLib > { > double ReadAndProcessSum(std::istream&); > } > > int main() > { > using namespace std; > double sum; > > try > { > sum = MyLib::ReadAndProcessSum(cin); > } > catch (const ios::failure& error) // <===== > error right here > { > cerr << "I/O exception: " << error.what() << endl; > return EXIT_FAILURE; > } > catch (const exception& error) > { > cerr << "standard exception: " << error.what() << endl; > return EXIT_FAILURE; > } > catch ( ... ) > { > cerr << "unknown exception" << endl; > return EXIT_FAILURE; > } > > // print sum > cout << "sum: " << sum << endl; > } > > .... that one doesn't. Any help? Thanks. > > Compiling: Summain.cpp > In function `int main()': > Summain.cpp (20) Error: parse error before `&' > Summain.cpp (24) Error: confused by earlier errors; bailing out > There were some errors > > > Chris > > > >
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |