title: C++: error: exception handling disabled, use -fexceptions to enable
body: <p>I am trying to compile simple code with -fno-exceptions flag. Its giving error. </p>
  
  <p>Please let me know how to suppress this. I am using gcc version 4.6.3</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int main () {
    try
    {
      throw 20;
    }
    catch (int e)
    {
      cout &lt;&lt; "An exception occurred. Exception Nr. " &lt;&lt; e &lt;&lt; '\n';
    }
    return 0;
  }
  </code></pre>
  
  <p><strong>Log</strong></p>
  
  <pre><code>&gt; g++ throw.cc -o out -fno-exceptions
  throw.cc: In function ‘int main()’:
  throw.cc:10:11: error: exception handling disabled, use -fexceptions to enable
  throw.cc:14:56: error: ‘e’ was not declared in this scope
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>I have a client code which have lot throws like this. I have to integrate this in my project and I can't control compilation flags to build(which will come from config which has -fno-exceptions enabled). I wanted a quick work around that I can suggest.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I found a workaround see below for my answer.</p>