gpt4 book ai didi

使用 'asm' 指令编译 c 源代码

转载 作者:太空宇宙 更新时间:2023-11-04 02:34:34 24 4
gpt4 key购买 nike

<分区>

我正在尝试编译 this c source file使用 cl.exe(来自 Visual Studio)。编译失败的具体问题代码是:

#include <stdio.h>

static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
{
/* ecx is often an input as well as an output. */
asm volatile("cpuid"
: "=a" (*eax),
"=b" (*ebx),
"=c" (*ecx),
"=d" (*edx)
: "0" (*eax), "2" (*ecx));
}

我看到了这个失败:

C:\>cl sgx.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24213.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

sgx.c
sgx.c(7): error C2065: 'asm': undeclared identifier
sgx.c(7): error C2143: syntax error: missing ';' before 'volatile'

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com