If the compiler converts the high level language (like C++, for example) to the machine code to be executed by the Microprocessor.

Why can't the programs which run on Windows run on Mac or Linux?

有帮助吗?

解决方案

As long as a high-level program really is written 100% in C++ or another language and uses no external code at all, it is in fact relatively easy to make it compile on any OS with a compiler, and it will behave in the same way.

The difficulty is that virtually every program uses libraries of the OS, e.g. for Input/Output, UI drawing etc., and these are different on every OS under the sun. In practice, it is impossible to get anything realistic done in a computer program without taking advantage of the massive amount of helper code present in the OS, or in libraries shipped with the OS. This is what makes porting harder - usually not actually difficult, just tedious.

其他提示

Because a lot of your calls are referencing elements of the OS. Like drawing, acessing the filesystem. These calls have to be translated, like Java or Qt.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top