[Top][All Lists]

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

Re: Compile with no exceptions

From: Paul Pluzhnikov
Subject: Re: Compile with no exceptions
Date: Thu, 31 Aug 2006 08:32:18 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

kitschen <> writes:

> Is it possible in g++ (3.2) to compile without exception handling? 
> (turn off all exceptions)

Sure: -fno-exceptions

> I would like to estimate the performance gain on my code without
> exception. Is this possible without rewriting the code and taking out
> all try and catch etc?

Try/catch compiles fine with '-fno-exceptions' (which was a surprize
to me) with g++ 3.3.3; but not with any other version of gcc I tried;
must be a bug in 3.3.3 ...

Throw doesn't compile with g++ 3.3.3 either.

Obviously, if you are *using* exceptions, you can't just tell the
compiler "ignore what I wrote, and compile something else instead".
You might as well try to compile output from /dev/random.

If you want to experimentally disable exceptions, you have to do
it with macros. Something like:

  # define TRY try 
  # define CATCH(a) catch (a)
  # define TRY if(1) 
  # define CATCH(a) else if (0) {


    TRY { something(); } CATCH(int x) { handle_exception(); }

You'll need to get more creative if handle_exception() needs to
reference 'x'.

In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]