__ud2

Microsoft 专用

生成一个未定义命令。

void __ud2();

备注

,如果执行了未定义命令,则处理器会引发无效操作码异常。

__ud2 功能与 UD2 指令等效,并且只能在的核心架构。 有关更多信息,搜索文档, “Intel 体系结构软件开发人员的准则,数量 2:设置命令在该站点引用, Intel Corporation ”。

要求

内部

体系结构

__ud2

x86, x64

头文件 <intrin.h>

示例

下面的示例执行了未定义命令,将引发异常。 异常处理程序从零然后将返回代码添加到一个。

// __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;
}
  
  
  
  
  

请参见

参考

编译器内部函数