From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,e76a94c6438141e2,start X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2004-02-06 13:47:47 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!bos-service1.ext.raytheon.com!dfw-service2.ext.ray.com.POSTED!53ab2750!not-for-mail Newsgroups: comp.unix.tru64 Subject: c++ exception handling From: Scott Schindler User-Agent: Xnews/06.08.25 Message-ID: <7YTUb.10$tv3.0@dfw-service2.ext.ray.com> Date: Fri, 06 Feb 2004 21:47:47 GMT NNTP-Posting-Host: 147.24.155.62 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.ray.com 1076104067 147.24.155.62 (Fri, 06 Feb 2004 15:47:47 CST) NNTP-Posting-Date: Fri, 06 Feb 2004 15:47:47 CST Organization: Raytheon Company Xref: archiver1.google.com comp.unix.tru64:11169 I am trying to test an exception handling scheme in c++ on a unix machine (uname -a produces the following output: OSF1 *removed* V5.1 1885 alpha alpha) Here is the code: #include #include int main() { try { int numerator(100); int denominator(0); // Should cause an exception to occur. int result(numerator/denominator); } catch (...) { std::cout << "Exception caught by catch all.\n"; } return 0; } compiling with the following command: cxx -std strict_ansi -std strict_ansi_errors -g -O0 test.cpp running with the following command: a.out produces the following output: Floating exception I have also tried the following example: #include #include #include extern "C" { void handler(int i) { std::cout << "Exception caught by the signal handler.\n"; throw 1; } } int main() { sginal(SIGFPE, handler); try { int numerator(100); int denominator(0); // Should cause an exception to occur. int result(numerator/denominator); } catch (...) { std::cout << "Exception caught by catch all.\n"; } return 0; } Using the same compilation and running commands produces the following output: Exception caught by the signal handler. Exception caught by catch all. I am not sure that I want to implement the second method. Is there a pure c++ way of having the program catch the exception. Thank you for your time, Scott Schindler