开发者

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

  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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜