编译 Neko VM OS X 时出错

发布于 2024-07-19 20:21:24 字数 1340 浏览 4 评论 0原文

我正在尝试使用 GCC 4.01 在 Mac OS X (10.5.7) 上编译 Neko VM完全卡住了,因为它在编译时停止说:

vm/threads.c:202: error: conflicting types for 'neko_thread_register'
vm/neko_vm.h:37: error: previous declaration of 'neko_thread_register' was here

我尝试过谷歌搜索这个,有些人说这是因为缺乏“原型”,有些人说这是因为标头包含被完成了好几次,但我真的找不到任何那些。

threads.c:202 中受影响的行看起来像这样:

EXTERN bool neko_thread_register( bool t ) {

neko_vm.h:37< 中受影响的行/a> 看起来像这样:

EXTERN bool neko_thread_register( bool t );

除了其中一个是另一个的实现之外,我看不出它们有任何区别。

我使用的编译器命令是:

cc -Wall -O3 -v -fPIC -fomit-frame-pointer -I vm -D_GNU_SOURCE -arch i386 -L/usr/local/lib -L/opt/local/lib -I/opt/local/include  -o vm/threads.o -c vm/threads.c

我很感激一些关于我在这里可以做什么的想法,我真的不知道从这里去哪里。

我正在尝试编译的 Neko 代码的镜像可以在此处找到。

谢谢!

I'm trying to compile the Neko VM on Mac OS X (10.5.7) using GCC 4.01 and I'm completely stuck, because it stops while compiling saying:

vm/threads.c:202: error: conflicting types for 'neko_thread_register'
vm/neko_vm.h:37: error: previous declaration of 'neko_thread_register' was here

I've tried googling this and some say it's because of lack of a "prototype" and some say it's because of a header include being done several times, and I can't really find any of those.

The affected line in threads.c:202 looks like this:

EXTERN bool neko_thread_register( bool t ) {

And the affected line in neko_vm.h:37 looks like this:

EXTERN bool neko_thread_register( bool t );

I can't see any difference in them, besides one of them being the implementation of the other.

The compiler command I'm using is:

cc -Wall -O3 -v -fPIC -fomit-frame-pointer -I vm -D_GNU_SOURCE -arch i386 -L/usr/local/lib -L/opt/local/lib -I/opt/local/include  -o vm/threads.o -c vm/threads.c

I'd appreciate some ideas on what i might be able to do here, I don't really know where to go from here.

A mirror of the code for Neko which I'm trying to compile can be found here.

Thanks!

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

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

发布评论

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

评论(3

暗地喜欢 2024-07-26 20:21:24

您是否尝试过单独编译该文件并输出预处理版本? 可能是范围或链接宏在头文件和实现文件之间的某个位置被修改——“bool”类型也是如此,它通常是由系统头定义的宏。

根据此处的 GCC 4.2 文档,您应该需要将 -E 标志添加到上面的编译行,并且您应该将 -o vm/threads.o 更改为 -o vm/ threads.i 因此会创建一个具有正确扩展名的文件(.i 本质上意味着“预处理文件”)。

Have you tried compiling that file alone and outputting the preprocessed version? It could be that the scope or linkage macros are being modified somewhere in between the header file and the implementation file-- the same could be true of the 'bool' type, which is usually a macro defined by a system header.

According to the GCC 4.2 docs here, you should need to add the -E flag to the compilation line above, and you ought to change -o vm/threads.o to -o vm/threads.i so a file with the correct extension is created (.i means 'preprocessed file', essentially).

删除→记忆 2024-07-26 20:21:24

首先,确保将其编译为 C,而不是 C++。

其次,在没有看到代码的情况下,几乎不可能说出问题是什么。
但阅读错误消息通常很有帮助(甚至在您用 google 搜索它们之前):

显然 neko_thread_register 被声明了两次,一次在threads.c:202中,一次在neko_vm.h:37中,并且这两个声明不同的(冲突的)类型。 那么看看这两个声明。 如果您看不出它们有问题,请向我们展示一些代码。

至少,看到这两行代码是必要的。 最有可能的是,类型是 typedef 或宏或类似的东西,然后我们还需要查看它们的定义位置。

在看不到代码的情况下,我们所能做的就是重复编译器错误。 “neko_thread_register 在指定的行中有两个相互冲突的定义。”

First, make sure you compile this as C, not C++.

Second, without seeing the code, it's pretty much impossible to say what the problem is.
But reading the error messages is often helpful (even before you google them):

Apparently neko_thread_register is declared twice, once in threads.c:202 and once in neko_vm.h:37, and the two declarations have different (conflicting) types. So look at the two declarations. If you can't see a problem with them, show us some code.

At the very least, seeing those two lines of code would be necessary. Most likely, the types are typedefs or macros or something similar, and then we'd need to see where they are defined as well.

Without seeing the code, all we can do is repeat the compiler error. "neko_thread_register has two conflicting definitions, at the lines specified."

空袭的梦i 2024-07-26 20:21:24

取消注释了这一行:

# For OSX
#
# MACOSX = 1   <-- this one

您是否在 makefile 中

Did you uncomment this line:

# For OSX
#
# MACOSX = 1   <-- this one

In the makefile?

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