编写一个可移植的C程序 - 考虑到哪些东西呢? [英] Writing a portable C program - which things to consider?

查看:127
本文介绍了编写一个可移植的C程序 - 考虑到哪些东西呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关在大学的一个项目,我需要扩展现有的C应用程序,它应当在各种商业和非商业UNIX系统(FreeBSD的,Solaris和AIX等)的运行结束

For a project at university I need to extend an existing C application, which shall in the end run on a wide variety of commercial and non-commercial unix systems (FreeBSD, Solaris, AIX, etc.).

这件事我必须要考虑的时候我想写一个C程序这是最轻便的?

Which things do I have to consider when I want to write a C program which is most portable?

推荐答案

我能给的最好的建议,是因为你去每天移动到不同的平台,测试。结果
这将使平台的差异伸出像突兀,教你的可移植性问题在同一时间。

The best advice I can give, is to move to a different platform every day, testing as you go.
This will make the platform differences stick out like a sore thumb, and teach you the portability issues at the same time.

保存为最终的跨平台测试,将导致失败。

Saving the cross platform testing for the end, will lead to failure.

这一边


  • 整数大小可能会有所不同。

  • 浮点数可能被重新presented不同。

  • 整数可以有不同的endianism。

  • 编译选项可能会有所不同。

  • 包括文件名可能会有所不同。

  • 位域的实现会有所不同。

这通常是设置你的编译器警告等级可达尽可能高的一个好主意,
看到各种各样的东西编译器可以抱怨的。

It is generally a good idea to set your compiler warning level up as high as possible, to see the sorts of things the compiler can complain about.

这篇关于编写一个可移植的C程序 - 考虑到哪些东西呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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