Is C++ platform dependent?

后端 未结 7 2079
傲寒
傲寒 2020-12-04 16:33

Can we say that C++ is platform dependent?

I know that C++ uses compiler, and those compiler are different for different platforms. When we compile C++ code using co

7条回答
  •  温柔的废话
    2020-12-04 17:34

    What makes a language, such as C++, "platform independent" is that it doesn't rely upon language constructs that are heavily favored by a given CPU architecture. Assembly language, for example and in contrast, is quite specific to a CPU architecture and instruction set. The front-end of a C++ compiler (parsing and semantic analysis) can be the same or basically the same for any computing platform it's targeted for. However, there still needs to be a platform or CPU specific code generator (e.g., for x86, ARM, etc).

    An EXE is a binary file specifically compiled and code-generated for DOS/Windows platform. It's structure is known by the DOS/Windows system and it contains information for how to locate the executable in memory as well as all of the instruction codes specific to CPU/platform for it to run. As indicated by Oleksandr, its specific format can be found, for example, on Wikipedia.

提交回复
热议问题