Enable C++ exceptions in Visual Studio 2010 compilation options
I'm trying to compile this source code :
// exception_set_unexpect开发者_如何学Pythoned.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 ?
Right click on your project -> Properties -> Configuration Properties -> C/C++ -> Command Line
Put your flags in the command Line
To set this compiler option in the Visual Studio development environment
- Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
- Click the C/C++ folder.
- Click the Code Generation property page.
- Set Enable C++ Exceptions to Yes (/EHsc).
- Click the Command Line property page.
- Type the compiler option in the Additional Options box (/c).
More info here.
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.
精彩评论