Enable C ++ exceptions in Visual Studio 2010 compilation options

I am 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 to add compile with: /c /EHsc in Visual Studio 2010?

+7
c ++ c ++ 11 visual-studio-2010
source share
3 answers

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

Put your flags on the command line

+5
source share

To set this compiler option in the Visual Studio development environment

  • Open the Project Page Properties dialog box. See How to open the project properties pages for more information.
  • Click the C / C ++ folder.
  • Go to the code generation properties page.
  • Set Enable C ++ Exceptions for Yes (/ EHsc).
  • Go to the command line properties page.
  • Enter the compiler option in the Advanced Options (/ c) field.

More details here .

+4
source share

The "/ EHsc" parameter is located in the "Code Generation" section in the project settings.

The "/ c" option, I'm not sure what it is ("keep comments" one?)?

or maybe I'm reading the original question incorrectly.

M.

0
source share

All Articles