翻訳への提案を行います
 
他のユーザーによる提案:

progress indicator
他の提案はありません。
クリックして評価とフィードバックをお寄せください
MSDN
MSDN ライブラリ
Visual Studio 2010
Visual Studio
Visual Studio の言語
Visual C++
C/C++ プログラムのビルド
コンパイラ オプション
 /EH (例外処理モデル)
すべて縮小/すべて展開 すべて縮小
コンテンツの表示:   英語と日本語を並べて表示コンテンツの表示: 英語と日本語を並べて表示
Visual Studio 2010 - Visual C++
/EH (Exception Handling Model)

Specifies the model of exception handling to be used by the compiler and destroys C++ objects that will go out of scope as a result of the exception. If /EH is not specified, the compiler will catch structured and C++ exceptions, but will not destroy C++ objects that will go out of scope as a result of the exception.

/EH{s|a}[c][-]
a

The exception-handling model that catches asynchronous (structured) and synchronous (C++) exceptions.

s

The exception-handling model that catches C++ exceptions only and tells the compiler to assume that extern C functions do throw an exception.

c

If used with s (/EHsc), catches C++ exceptions only and tells the compiler to assume that extern C functions never throw a C++ exception. /EHca is equivalent to /EHa.

Use /EHs to specify the synchronous exception handling model (C++ exception handling without structured exception handling exceptions). If you use /EHs, then your catch clause will not catch asynchronous exceptions. Also, all objects in scope when the asynchronous exception is generated will not be destroyed even if the asynchronous exception is handled. Under /EHs, catch(...) will only catch C++ exceptions. Access violations and System..::.Exception exceptions will not be caught.

Use /EHa to specify the asynchronous exception handling model (C++ exception handling with structured exception handling exceptions). /EHa may result in a less performant image because the compiler will not optimize a try block as aggressively, even if the compiler does not see a throw.

Use /EHa if you want to catch an exception raised with something other than a throw. The following sample will generate an exception:

// compiler_options_EHA.cpp
// compile with: /EHa
#include <iostream>
#include <excpt.h>
using namespace std;

void fail() {   // generates SE and attempts to catch it using catch(...)
   try {
      int i = 0, j = 1;
      j /= i;   // This will throw a SE (divide by zero).
      printf("%d", j); 
   }
   catch(...) {   // catch block will only be executed under /EHa
      cout<<"Caught an exception in catch(...)."<<endl;
   }
}

int main() {
   __try {
      fail(); 
   }

   // __except will only catch an exception here
   __except(EXCEPTION_EXECUTE_HANDLER) {   
   // if the exception was not caught by the catch(...) inside fail()
      cout << "An exception was caught in __except." << endl;
   }
}

The /EHc option requires that /EHs or /EHa is specified. Using /clr (Common Language Runtime Compilation) implies /EHa (/clr /EHa is redundant). The compiler will generate an error if /EHs[c] is used after /clr. Optimizations will not affect this behavior. When an exception is caught, the compiler invokes the class destructor or destructors for the object or objects that are in the same scope as the exception. When an exception is not caught, those destructors are not run.

See _set_se_translator for exception handling restrictions under /clr.

The option can be cleared by the symbol -. For example, /EHsc- is interpreted as /EHs /EHc- and is equivalent to /EHs.

See Exception Handling: Default Synchronous Exception Model for more information.

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. Modify the Enable C++ Exceptions property.

Alternately, you can use the following procedure:

To set this compiler option in the Visual Studio development environment

  1. Click the C/C++ folder.

  2. Click the Code Generation property page.

  3. Set Enable C++ Exceptions to No.

  4. Click the Command Line property page.

  5. Type the compiler option in the Additional Options box.

To set this compiler option programmatically

Visual Studio 2010 - Visual C++
/EH (例外処理モデル)

コンパイラで使用する例外処理モデルを指定し、例外の結果として適用範囲の外になる C++ オブジェクトを破棄します。 /EH が指定されていない場合、コンパイラは構造化例外と C++ 例外をキャッチし、例外の結果として適用範囲の外になる C++ オブジェクトを破棄しません。

/EH{s|a}[c][-]
a

非同期 (構造化) 例外と同期 (C++) 例外をキャッチする例外処理モデル。

s

C++ 例外のみをキャッチし、extern C 関数が例外をスローすると想定するようにコンパイラに指示する例外処理モデル。

c

s (/EHsc) と共に使用すると、C++ 例外のみをキャッチし、extern C 関数が C++ 例外をスローしないと想定するようにコンパイラに指示します。 /EHca/EHa と同じです。

/EHs を使用して、同期例外処理モデル (構造化例外処理の例外のない C++ 例外処理) を指定します。 /EHs を使用すると、catch 句は非同期例外をキャッチしません。 また、非同期例外が処理される場合であっても、非同期例外の生成時にスコープ内にあるすべてのオブジェクトは破棄されません。 /EHs が指定されている場合は、catch(...) は C++ 例外だけをキャッチします。 アクセス違反および System..::.Exception 例外はキャッチされません。

/EHa を使用して、非同期例外処理モデル (構造化例外処理の例外のある C++ 例外処理) を指定します。 /EHa を指定すると、スローが確認されない場合であってもコンパイラは try ブロックの最適化を積極的に行わないため、イメージのパフォーマンスが低くなります。

throw 以外の方法で発生する例外をキャッチする場合は、/EHa を使用します。 次の例では例外が生成されます。

// compiler_options_EHA.cpp
// compile with: /EHa
#include <iostream>
#include <excpt.h>
using namespace std;

void fail() {   // generates SE and attempts to catch it using catch(...)
   try {
      int i = 0, j = 1;
      j /= i;   // This will throw a SE (divide by zero).
      printf("%d", j); 
   }
   catch(...) {   // catch block will only be executed under /EHa
      cout<<"Caught an exception in catch(...)."<<endl;
   }
}

int main() {
   __try {
      fail(); 
   }

   // __except will only catch an exception here
   __except(EXCEPTION_EXECUTE_HANDLER) {   
   // if the exception was not caught by the catch(...) inside fail()
      cout << "An exception was caught in __except." << endl;
   }
}

/EHc オプションでは、/EHs または /EHa を指定する必要があります。 /clr (共通言語ランタイムのコンパイル) を使用すると、/EHa が暗黙に指定されます (/clr /EHa とすると重複になります)。 /EHs[c]/clr の後で使用されると、コンパイラはエラーを生成します。 最適化処理は、この動作に影響しません。 例外がキャッチされると、例外オブジェクトまたは例外と同じスコープ内にあるオブジェクトに対して、コンパイラが 1 つまたは複数のクラス デストラクターを呼び出します。 例外がキャッチされない場合は、これらのデストラクターは実行されません。

/clr を指定する場合の例外処理の制約については、「_set_se_translator」を参照してください。

オプションは、マイナス記号 (-) でクリアできます。 たとえば、/EHsc-/EHs /EHc- と解釈され、/EHs と等価です。

詳細については、「Exception Handling: Default Synchronous Exception Model」を参照してください。

Visual Studio 開発環境でこのコンパイラ オプションを設定するには

  1. プロジェクトの [プロパティ ページ] ダイアログ ボックスを開きます。 詳細については、「方法 : プロジェクト プロパティ ページを開く」を参照してください。

  2. [C/C++] フォルダーをクリックします。

  3. [コード生成] プロパティ ページをクリックします。

  4. [C++ の例外を有効にする] プロパティを変更します。

または、次のプロシージャを使用できます。

Visual Studio 開発環境でこのコンパイラ オプションを設定するには

  1. [C/C++] フォルダーをクリックします。

  2. [コード生成] プロパティ ページをクリックします。

  3. [C++ の例外を有効にする][いいえ] に設定します。

  4. [コマンド ライン] プロパティ ページをクリックします。

  5. [追加のオプション]ボックスにコンパイラ オプションを入力します。

このコンパイラ オプションをコードから設定するには

コミュニティ コンテンツ   コミュニティ コンテンツとは
新しいコンテンツの追加 RSS  注釈
Processing
© 2012 Microsoft. All rights reserved. 使用条件 | 商標 | プライバシー
Page view tracker