__ud2
[このドキュメントはプレビュー版であり、後のリリースで変更されることがあります。 Blank topics are included as placeholders.]
Microsoft 固有の仕様 →
未定義命令が生成されます。
void __ud2();
解説
プロセッサが未定義の手順を実行すると無効なオペコードの例外が発生します。
__ud2 の関数は UD2 のマシン語命令とカーネル モードでのみ使用できます。 詳細については文書の検索「 Intel アーキテクチャのソフトウェア開発者の手動Volume 2: サイトの命令セットの参照です Intel Corporation 」。
必要条件
組み込み |
アーキテクチャ |
---|---|
__ud2 |
x86x64 |
ヘッダー ファイル <intrin.h>
使用例
次の例は例外を発生させる未定義手順を実行します。 例外ハンドラーはゼロから 1 つリターン コードを変更します。
// __ud2_intrinsic.cpp
#include <stdio.h>
#include <intrin.h>
#include <excpt.h>
// compile with /EHa
int main() {
// Initialize the return code to 0.
int ret = 0;
// Attempt to execute an undefined instruction.
printf("Before __ud2(). Return code = %d.\n", ret);
__try {
__ud2();
}
// Catch any exceptions and set the return code to 1.
__except(EXCEPTION_EXECUTE_HANDLER){
printf(" In the exception handler.\n");
ret = 1;
}
// Report the value of the return code.
printf("After __ud2(). Return code = %d.\n", ret);
return ret;
}