Why is it difficult to write portable C programs?

前端 未结 10 2628
野的像风
野的像风 2020-12-14 03:50

I want to know, why is it too hard to make a program run in many OSes, like Windows and Linux, without including glue code. They all share the same architecture (x86), so I

10条回答
  •  太阳男子
    2020-12-14 04:13

    Obviously, some software requires OS specific features, but it's quite interesting to think what can be created in C without using such things:

    • A C or C++ compiler (though not all of the standard library)
    • An assembler for any assembly language
    • A linker for the above
    • An interpreter for a scripting language
    • Text processing tools like sed, grep etc.
    • A simple editor (anyone remember ed?)

    In fact, all the basic development tools can be developed (and historically were developed) in C without using OS-specific features.

提交回复
热议问题