[英]Issue defining a function in inline assembly and calling from c++
我正在嘗試編譯以下鏈接中提到的代碼。 我收到以下鏈接器錯誤:
/tmp/ccUVLIZ0.ltrans0.ltrans.o:在函數“ main”中:
:(。text.startup + 0x5):對“ one”的未定義引用
collect2:錯誤:ld返回1退出狀態
鏈接器看不到程序集定義?
代碼如下:
#include <stdio.h>
asm("_one: \n\
movl $1,%eax \n\
ret \n\
");
int one();
int main() {
printf("result: %d\n", one());
return 0;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.