www.delorie.com/archives/browse.cgi | search |
From: | "23yrold3yrold" <cbarry AT pangea DOT ca> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | DJGPP and the C++ standard |
Date: | Thu, 22 Mar 2001 17:15:39 -0600 |
Lines: | 112 |
X-Priority: | 3 |
X-MSMail-Priority: | Normal |
X-Newsreader: | Microsoft Outlook Express 5.00.2919.6600 |
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2919.6600 |
NNTP-Posting-Host: | news3 |
Message-ID: | <3aba8686_2@news4.newsfeeds.com> |
X-Comments: | This message was posted through Newsfeeds.com |
X-Comments2: | IMPORTANT: Newsfeeds.com does not condone, nor support, spam or any illegal or copyrighted postings. |
X-Comments3: | IMPORTANT: Under NO circumstances will postings containing illegal or copyrighted material through this service be tolerated!! |
X-Report: | Please report illegal or inappropriate use to <abuse AT newsfeeds DOT com> You may also use our online abuse reporting from: http://www.newsfeeds.com/abuseform.htm |
X-Abuse-Info: | Please be sure to forward a copy of ALL headers, INCLUDING the body (DO NOT SEND ATTACHMENTS) |
Organization: | Newsfeeds.com http://www.newsfeeds.com 73,000+ UNCENSORED Newsgroups. |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie 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 |