【发布时间】:2021-09-20 08:20:34
【问题描述】:
如果我这样做:
const char *str = "some assembly instructions";
asm(str);
CLion 会说“'asm' 中的预期字符串文字”
【问题讨论】:
标签: c assembly inline-assembly string-literals
如果我这样做:
const char *str = "some assembly instructions";
asm(str);
CLion 会说“'asm' 中的预期字符串文字”
【问题讨论】:
标签: c assembly inline-assembly string-literals
asm 不是在运行时调用的普通 C 函数,而是在编译时发出您指定的汇编代码的特殊指令。 asm 需要在编译时知道汇编指令,这只有在参数是字符串文字时才有可能:
正确:
asm("some instruction"); // "some instruction" is known at compile time
不正确:
asm(str); // at compile time it is potentially not known where
// str points to
结论:您不能将字符串文字以外的任何内容传递给asm。
【讨论】: