views:

45

answers:

3

I'm trying to compile this source code :

// exception_set_unexpected.cpp
// compile with: /c /EHsc
#include<exception>
#include<iostream>

using namespace std;

void unfunction( ) 
{
   cout << "I'll be back." << endl;
   terminate( );
}

int main( ) 
{
   unexpected_handler oldHand = set_unexpected( unfunction );
   unexpected( );
}

How can i add compile with: /c /EHsc option in Visual Studio 2010 ?

A: 

The "/EHsc" option is in the "Code Generation" section of the project settings.

The "/c" option, i'm not certain what is it (the "keep comments" one ?) ?

or maybe I'm mis-reading the original question.

M.

Max
+2  A: 

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
  2. Click the C/C++ folder.
  3. Click the Code Generation property page.
  4. Set Enable C++ Exceptions to Yes (/EHsc).
  5. Click the Command Line property page.
  6. Type the compiler option in the Additional Options box (/c).

More info here.

Kirill V. Lyadvinsky
+1  A: 

Right click on your project -> Properties -> Configuration Properties -> C/C++ -> Command Line

Put your flags in the command Line

DumbCoder