代码可移植性 [英] code portability

查看:86
本文介绍了代码可移植性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题更通用,但它涉及我认为ANSI标准C

和便携性。


我碰巧是多个系统管理员我的用户请求的应用程序是OpenSource

社区的一部分。平台和大量的b $ b b。许多(如果不是大多数)这些应用程序强烈要求GNU编译套件的存在才能正常工作。我的假设是

这是由于作者使用GNU套件创建应用程序。

许多要求/要求的工具是make的GNU替换,

configure,加载器,最后是C编译器本身。我要去的地方

,OpenSource社区作为一个整体致力于

,至少鼓励其贡献成员遵守ANSI

编程标准?


我担心的是,作为管理员,我有时被迫将这些

应用程序移植到运行该程序的多个平台上相同的操作系统和用户

社区越来越坚持OpenSource应用程序将因为编码缺乏可移植性而出现问题?我完全意识到

独立开发者可能符合也可能不符合标准,但又是否至少鼓励



常见问题的11.32似乎至少勾勒出了我所要求的症结。

如果我将我的家用机器加载到鳃上将是所有开源编译器

应用程序( gcc,imake,autoconfig等....)我的应用程序是否需要编译和链接并加载一致?

解决方案



Eigenvector写道:


我的问题更通用,但它涉及我认为的ANSI标准C

和便携性。


我碰巧是一个多平台的系统管理员,而且我的用户请求的应用程序是一个很多的b / b
OpenSource

社区的一部分。许多(如果不是大多数)这些应用程序强烈要求GNU编译套件的存在才能正常工作。我的假设是

这是由于作者使用GNU套件创建应用程序。

许多要求/要求的工具是make的GNU替换,

configure,加载器,最后是C编译器本身。我要去的地方

,OpenSource社区作为一个整体致力于

,至少鼓励其贡献成员遵守ANSI

编程标准?



GCC尝试符合C90和C99,并且在许多方面它都在那里。

如果你禁用GNU扩展[或者只是平原不要使用它们,因为

你没有写内核你可能不需要它们你很漂亮

多少套。


我担心的是,作为管理员,我有时被迫将这些

应用程序移植到运行相同操作系统的多个平台上用户

社区越来越坚持OpenSource应用程序因为编码缺乏可移植性而会出现问题吗?我完全意识到

独立开发者可能会或可能不会符合标准,但同样至少是鼓励b
$ b?



C库[glibc]和其他库[pthreads,sockets等]遵循各种UNIX,POSIX和ANSI标准的
。有一些小问题(对于

实例,pthreads是Linux中glibc的一部分,但在其他

UNIX中却没有)但是大多数情况下源兼容性都存在。 />


11.32的FAQ似乎至少勾勒出了我所要求的症结。

如果我将家用机器装到鳃上所有开源编译器

应用程序(gcc,imake,autoconfig等等)我的应用程序是否会编译并链接和加载符合?



阅读手册页。确保您使用的功能符合某些

标准,并且不是特定于您的操作系统(例如,不是Linux)。


您会感到惊讶在UNIX,BSD和Linux中,有多少标准库是API




Tom

< br>



Tom St Denis < to ******** @ gmail.comwrote in message

news:11 ********************** @ m73g2000cwd.googlegr oups.com ...


>

Eigenvector写道:


>我的问题更通用,但它涉及我认为的ANSI
标准C
和可移植性。

我碰巧是一个多个系统管理员平台以及我的用户请求的应用程序很多都是OpenSource
社区的一部分。许多(如果不是大多数)应用程序强烈要求GNU编译套件的存在才能正常工作。我的假设是
这是由于作者使用GNU套件创建应用程序。
许多工具请求/需要GNU替换make,
configure ,加载器,最后是C编译器本身。我要去的地方是,OpenSource社区作为一个整体致力于
至少鼓励其贡献成员遵守ANSI
标准编程吗?



GCC尝试符合C90和C99,并且在许多方面它都在那里。

如果禁用GNU扩展[或者只是平原不要使用它们,因为

你没有写内核你可能不需要它们你很漂亮

多少套。



提交到档案的程序员怎么样?这主要是在那里我看到了巨大的gcc和imake要求。事实上,我已经开始尝试编译应用程序 - 例如gcc使用我的本机英特尔或xlC

编译器而没有运气。再一次,这不是关于如何编译GCC的问题,

而是OpenSource社区试图将符合ANSI b标准符合ANSI标准的经验?
< blockquote class =post_quotes>
>


>我担心的是,作为管理员,我有时被迫将这些应用程序移植到运行相同操作系统和用户的多个平台上社区变得越来越坚持OpenSource应用程序因为编码缺乏可移植性而出现问题?我完全意识到
独立开发者可能符合也可能不符合标准,但至少还是鼓励它至少鼓励?



C库[glibc]和其他库[pthreads,sockets等]遵循各种UNIX,POSIX和ANSI标准的
。有一些小问题(对于

实例,pthreads是Linux中glibc的一部分,但在其他

UNIX中却没有)但是大多数情况下源兼容性都存在。 />


> 11.32的常见问题解答似乎至少勾勒出了我所要求的症结。
如果我把我的家用机器装到鳃上就会全部打开源代码编译器
应用程序(gcc,imake,autoconfig等)将我的应用程序
我编译和链接并加载符合?



阅读手册页。确保您使用的功能符合某些

标准,并且不是特定于您的操作系统(例如,不是Linux)。


您会感到惊讶在UNIX,BSD和Linux中,有多少标准库是API




Tom



Eigenvector说:


< snip>


我在哪里用这个来b / b
,OpenSource社区作为一个整体致力于

,至少鼓励其贡献成员遵守ANSI

编程标准?



不幸的是,我非常怀疑。


我担心的是,作为管理员,我有时候被迫将这些

应用程序移植到运行相同操作系统和用户的多个平台上

社区对OpenSource应用程序的依赖性越来越大

由于编码缺乏可移植性而出现问题?



它们完全有可能。不幸的是,开源代码一般来说并不是因为它的健壮性或可移植性而闻名。实际上,

我只能想到一种源代码库,它不像开源代码那样可靠性低,而且便于携带 - 而且这是一个封闭的源代码。


我完全意识到独立开发者可能会或可能不会符合标准的b $ b b再次

是不是至少鼓励?



我们在comp.lang.c中做了一点,但我怀疑它是否足以使

超过差不多。


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上面的域名(但显然放弃了www)


My question is more generic, but it involves what I consider ANSI standard C
and portability.

I happen to be a system admin for multiple platforms and as such a lot of
the applications that my users request are a part of the OpenSource
community. Many if not most of those applications strongly require the
presence of the GNU compiling suite to work properly. My assumption is that
this is due to the author/s creating the applications with the GNU suite.
Many of the tools requested/required are GNU replacements for make,
configure, the loader, and lastly the C compiler itself. Where I''m going
with this is, has the OpenSource community as a whole committed itself to at
the very least encouraging its contributing members to conform to ANSI
standards of programming?

My concern is that as an admin I am sometimes compelled to port these
applications to multiple platforms running the same OS and as the user
community becomes more and more insistent on OpenSource applications will
gotcha''s appear due to lack of portability in coding? I fully realize that
independent developers may or may not conform to standards, but again is it
at least encouraged?

11.32 of the FAQ seemed to at least outline the crux of what I am asking.
If I loaded up my home machine to the gills will all open source compiler
applications (gcc, imake, autoconfig, etc....) would my applications that I
compile and link and load conform?

解决方案


Eigenvector wrote:

My question is more generic, but it involves what I consider ANSI standard C
and portability.

I happen to be a system admin for multiple platforms and as such a lot of
the applications that my users request are a part of the OpenSource
community. Many if not most of those applications strongly require the
presence of the GNU compiling suite to work properly. My assumption is that
this is due to the author/s creating the applications with the GNU suite.
Many of the tools requested/required are GNU replacements for make,
configure, the loader, and lastly the C compiler itself. Where I''m going
with this is, has the OpenSource community as a whole committed itself to at
the very least encouraging its contributing members to conform to ANSI
standards of programming?

GCC attempts to conform to C90 and C99 and in many regards it''s there.
If you disable GNU extensions [or just plain don''t use them, cuz if
you''re not writing a kernel you probably don''t need them] you''re pretty
much set.

My concern is that as an admin I am sometimes compelled to port these
applications to multiple platforms running the same OS and as the user
community becomes more and more insistent on OpenSource applications will
gotcha''s appear due to lack of portability in coding? I fully realize that
independent developers may or may not conform to standards, but again is it
at least encouraged?

The C library [glibc] and other libs [pthreads, sockets, etc] follow
various UNIX, POSIX and ANSI standards. There are minor gotchas (for
instance, pthreads is part of the glibc in Linux but not in other
UNIXes) but for the most part source compatibility is there.

11.32 of the FAQ seemed to at least outline the crux of what I am asking.
If I loaded up my home machine to the gills will all open source compiler
applications (gcc, imake, autoconfig, etc....) would my applications that I
compile and link and load conform?

Read the man pages. Make sure the functions you use conform to some
standard and are not specific to your OS (e.g. not Linux only).

You''d be surprised how much of the standard libraries are API
consistent across UNIX, BSD and Linux.

Tom



"Tom St Denis" <to********@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...

>
Eigenvector wrote:

>My question is more generic, but it involves what I consider ANSI
standard C
and portability.

I happen to be a system admin for multiple platforms and as such a lot of
the applications that my users request are a part of the OpenSource
community. Many if not most of those applications strongly require the
presence of the GNU compiling suite to work properly. My assumption is
that
this is due to the author/s creating the applications with the GNU suite.
Many of the tools requested/required are GNU replacements for make,
configure, the loader, and lastly the C compiler itself. Where I''m going
with this is, has the OpenSource community as a whole committed itself to
at
the very least encouraging its contributing members to conform to ANSI
standards of programming?


GCC attempts to conform to C90 and C99 and in many regards it''s there.
If you disable GNU extensions [or just plain don''t use them, cuz if
you''re not writing a kernel you probably don''t need them] you''re pretty
much set.

What about the programmers who submit to the archives? That is mainly where
I see massive gcc and imake requirements. In fact I have on occassion
attempted to compile applications - such as gcc using my native Intel or xlC
compilers without luck. Again this isn''t a question on how to compile GCC,
but rather is the experience that the OpenSource community tries to conform
to ANSI standards?

>

>My concern is that as an admin I am sometimes compelled to port these
applications to multiple platforms running the same OS and as the user
community becomes more and more insistent on OpenSource applications will
gotcha''s appear due to lack of portability in coding? I fully realize
that
independent developers may or may not conform to standards, but again is
it
at least encouraged?


The C library [glibc] and other libs [pthreads, sockets, etc] follow
various UNIX, POSIX and ANSI standards. There are minor gotchas (for
instance, pthreads is part of the glibc in Linux but not in other
UNIXes) but for the most part source compatibility is there.

>11.32 of the FAQ seemed to at least outline the crux of what I am asking.
If I loaded up my home machine to the gills will all open source compiler
applications (gcc, imake, autoconfig, etc....) would my applications that
I
compile and link and load conform?


Read the man pages. Make sure the functions you use conform to some
standard and are not specific to your OS (e.g. not Linux only).

You''d be surprised how much of the standard libraries are API
consistent across UNIX, BSD and Linux.

Tom



Eigenvector said:

<snip>

Where I''m going
with this is, has the OpenSource community as a whole committed itself to
at the very least encouraging its contributing members to conform to ANSI
standards of programming?

I doubt it very much, unfortunately.

My concern is that as an admin I am sometimes compelled to port these
applications to multiple platforms running the same OS and as the user
community becomes more and more insistent on OpenSource applications will
gotcha''s appear due to lack of portability in coding?

It''s entirely possible that they will. Unfortunately, open source code is
not, generally speaking, known for its robustness or portability. In fact,
I can think of only one kind of source base that is less robust and less
portable than open source code - and that''s closed source code.

I fully realize
that independent developers may or may not conform to standards, but again
is it at least encouraged?

We do our bit, here in comp.lang.c, but I doubt whether it''s enough to make
more than a small difference.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)


这篇关于代码可移植性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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