关于GCC内联汇编奇怪的错误信息 [英] strange error message about GCC inline assembly

查看:158
本文介绍了关于GCC内联汇编奇怪的错误信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int main()
{
    __asm__("movl $0x1,%%eax;
            movl $0x0,%%ebx;
            int $0x80;
            ":::"eax","ebx");
}

我尽量模拟的exit()在Linux中的行为。但在现代的Linux,我觉得这是很难做到的,既然有些退出处理程序将退出后,被称为()。
所以我写一个老版本的退出()。也许10年前,你可以在某些codeS中找到它。
我用gcc编译。

I try to simulate the behavior of exit() in Linux. But in modern Linux I find it's very difficult to do that since some exit handlers will be called after exit(). So I write an old version of exit(). Maybe 10 years ago you can find it in some codes. I compile it with gcc.

gcc -o exit exit.c

和它给了我这些消息。

exit.c: In function ‘main’:
exit.c:3:13: warning: missing terminating " character [enabled by default]
exit.c:3:5: error: missing terminating " character
exit.c:4:13: error: expected string literal before ‘movl’
exit.c:6:27: warning: missing terminating " character [enabled by default]
exit.c:6:13: error: missing terminating " character

我已经仔细检查了我的code和我不认为我的code是错误的。所以,那是什么?

I have carefully examined my code and I don't think my code is wrong. So what is that?

推荐答案

您已经不能嵌入引用的字符串内换行

You cannot have embedded newlines inside quoted strings

// bad
"two
lines"

重写为

// good
"two\n"
"lines"

在preprocessor将加入串无缝结合,以

The preprocessor will join the strings seamlessly, to

"two\nlines"

这篇关于关于GCC内联汇编奇怪的错误信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆