关于使用 c 进行汇编

发布于 2024-08-31 23:16:20 字数 784 浏览 1 评论 0原文

我刚刚完成了学校的一项必修任务,我即将完成它。

但后来我遇到了一些不熟悉的东西,头文件。 :(

我得到的是:

test-program.c
task_header.h
function1.s
function2.s
function3.s
function4.s

test-program.c:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "task_header.h"
.
..
...

task_header.h:

extern void function1(...);
extern void function2(...);
extern int  function3(...);
extern void function4(...);

然后我使用命令:

gcc -m32 -o runtest test-program.c function1.s function2.s function3.s function4.s

这是正确的方法吗,或者是否可以修改它?所以我可以输入: </

gcc -m32 -o runtest test-program.c

强><强>?

I've sort of just finished a mandatory task at school, and I'm about to deliver it.

But then I came across something that was unfamiliar, header files. :(

What I've got:

test-program.c
task_header.h
function1.s
function2.s
function3.s
function4.s

test-program.c:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "task_header.h"
.
..
...

task_header.h:

extern void function1(...);
extern void function2(...);
extern int  function3(...);
extern void function4(...);

And then I use the command:

gcc -m32 -o runtest test-program.c function1.s function2.s function3.s function4.s

Is this a proper way to do it, or is it possible to modify it? So I can type:

gcc -m32 -o runtest test-program.c

?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

像极了他 2024-09-07 23:16:20

这是一个完全合理的方法。

您通常也会编写一个 makefile,这样您只需键入 make 而不必记住构建指令。或者,也许只是一个脚本,这样您就可以执行./build.sh

我将保留这些文件作为练习。

That's a perfectly reasonable way to do it.

You'd normally write a makefile as well, so that you can just type make and not have to remember the build instructions. Or, perhaps, just a script so you can do a ./build.sh.

I'll leave those files as an exercise.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文