Re: exceptions in c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 11 Feb 2005 13:38:21 +0100 (CET)
Vincent Torri <torri@xxxxxxxxxxxxxxx> wrote:

> http://ldeniau.home.cern.ch/ldeniau/html/exception/exception.html
I tried the source code in attach compiled with:
gcc -mconsole -Wall -DDEBUG_THROW exc.c  exception.c -o exc
(I use mingw/msys, gcc 3.2.3)

if E_test is dfined to be 0 I obtain:

exc.c(30)-f: exception 'E_test' (id 0) thrown
unknow 1

I correctly throw 0, but I catch 1.

if I define E_test 1, 2 and so on it works well (wath I throw is what I
catch)

why this strage behaviour?

thanks

ps: I also tried under linux, gcc 2.96 with the same results



-- 
Massimiliano Cialdi
cialdi@xxxxxxxxx
m.cialdi@xxxxxxxx

#include <stdio.h>
#include <stdlib.h>
#include "exception.h"

enum { E_test = 0} exceptions;

static void f(void);

int main(void)
{
  try {
    f();
  }
  catch(E_test) {
    printf("E_test\n");
    fflush(stdout);
    continue;
  }
  catch_any {
    printf("unknow %d\n", exception);
    exit(1);
  }
  endtry;

  return 0;
}

void f(void)
{
  throw(E_test);
}

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux