Mail Archives: djgpp/1994/04/08/20:30:39

Date: Fri, 08 Apr 1994 15:54:07 +0200 (MET DST)
From: AT p14 DOT lemas DOT chg DOT imp DOT com (Hans Ellenberger)
Subject: C++ exception handling
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Lines: 48

Hello experts!

I have tried almost all permutations of try, catch & throw etc. without success

I thougt the code might look like the simple example below, but the compiler
rejects it:

//------------ --------------------------------------------------
#include <stdio.h>

class error {
int ee;
error(int i) {ee = i;}
void report() {printf("Error %i\n",ee);}

int xdiv(int a, int b)
throw (error) // or raises error ??
  if (b==0) throw error(1);
  return a / b;

int i;
  for (i=3; i>=0; i--){
     try {
        printf("9/%i = %i\n",i,xdiv(9,i));
     catch (error& e){;
// ---- EOF ---

I also tried all compiler switches like -ansi-exceptions, but then gcc
complained 'unknown switch'...

Many thanks and regards

Hans Ellenberger

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019