我想知道在Windows中开发的相同代码是否可以在Ubuntu中使用? [英] I would like to know can the same code developed in Windows can be used in Ubuntu?
本文介绍了我想知道在Windows中开发的相同代码是否可以在Ubuntu中使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道我在Windows操作系统中开发'C'代码。如果我接受代码并在Ubuntu中运行它将工作。所有必须修改以使其工作的区域是什么。
Hi,
I would like to know i am developing a 'C' codes in Windows operating system. If i take the code and run it in Ubuntu will it work. What are all the areas that has to be modified to make it work.
推荐答案
C
源代码,由本身是可移植的,即你可以在Windows
和Linux
上编译相同的源代码(Ubuntu
是Linux
)并获得一个显示相同行为的程序。
然而,当您与<$进行交互时c $ c> OS API 调用(以及除了普通程序之外的所有程序)都会破坏可移植性,因为例如Windows提供了Sleep
调用而Linux没有。因此,大多数C
非平凡程序都是不可移植的。
如果您的目标是可移植性,那么有一些解决方法:看看,对于例如,在 Cygwin [ ^ ]。
如果你没有遇到C
,那么你可以考虑'写一次运行无处不在的解决方案(即 Java [ ^ ])或C#
(可在Linux $上获得c $ c>通过 Mono [ ^ ])。
C
source code, by itself is portable, i.e. you may compile the same source code both onWindows
and onLinux
(Ubuntu
isLinux
) and obtain a program showing the same behviour.
However, as you interact withOS API
calls (and all but trivial programs do it) the portability is broken, because, for instance Windows provides aSleep
call while Linux does not. So most ofC
non-trivial programs are non portable.
If you aim to portability, however, there are workarounds: have a look, for instance, at Cygwin[^].
If you aren't stuck withC
, then you may consider the 'write once run everywhere' solution (that is Java[^]) orC#
(available onLinux
via Mono[^]).
这篇关于我想知道在Windows中开发的相同代码是否可以在Ubuntu中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文