我怎么能编译和运行这个1989年编写的C程序? [英] How can I compile and run this 1989 written C program?

查看:267
本文介绍了我怎么能编译和运行这个1989年编写的C程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现这个惊人的一块工作由亚瑟·惠特尼 - <一个href=\"http://www.jsoftware.com/jwiki/Essays/Incunabulum\">http://www.jsoftware.com/jwiki/Essays/Incunabulum

I found this amazing piece of work by Arthur Whitney - http://www.jsoftware.com/jwiki/Essays/Incunabulum

它编译了一些警告

$ gcc-4.7 incuna.c -o incuna.o
incuna.c: In function 'ma':
incuna.c:8:15: warning: incompatible implicit declaration of built-in function 'malloc' [enabled by default]
incuna.c: In function 'pi':
incuna.c:26:7: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
incuna.c: In function 'nl':
incuna.c:26:24: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
incuna.c: In function 'pr':
incuna.c:28:10: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
incuna.c: In function 'ex':
incuna.c:35:36: warning: assignment makes integer from pointer without a cast [enabled by default]
incuna.c:35:25: warning: return makes pointer from integer without a cast [enabled by default]
incuna.c: In function 'noun':
incuna.c:37:57: warning: return makes integer from pointer without a cast [enabled by default]
incuna.c: In function 'wd':
incuna.c:39:21: warning: incompatible implicit declaration of built-in function 'strlen' [enabled by default]

但segfaulted上输入基本输入 1 + 1

./incuna.o
warning: this program uses gets(), which is unsafe.
1 + 1
[1]    11525 segmentation fault  ./incuna.o

我猜这事做与C编译器的区别自1989年以来。

I'm guessing this has something to do with the difference in C compiler since 1989.

如何将能够运行这个?我能得到这个工作在最近的Linux / Mac吗?或在VirtualBox的VM?还是别的什么?

How would I be able to run this? Can I get this working on recent Linux/Mac? or on a VirtualBox VM? or anything else?

我的谷歌搜索却一无所获有关。

My Google searches turned up nothing related.

推荐答案

它转换指针 INT 反之亦然。这打破与它们有不同的大小的64位架构。

It converts pointers to int and long and vice-versa. This breaks with 64-bit architectures in which they have different sizes.

编译它已获得32位的目标。例如,用-arch i386的铛使用/ LLVM Mac OS X上。

Compile it for a 32-bit target. E.g., with "-arch i386" using clang/LLVM on Mac OS X.

这篇关于我怎么能编译和运行这个1989年编写的C程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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