Both standard C and standard C + + are source-level cross-platform, meaning that code written in standard C + + will run under Windows after it is compiled under Windows, and can be run under unix/linux after compiling under Unix/linux. C language can cross the platform mainly because each platform includes Dos,windows,linux,unix and so on have C compiler, as long as the source code is the same, the compiler compiled binary files will achieve the same function (not including cross-platform system calls). However, these binaries are not the same, and the executables in Linux generally do not run in Windows because they are two completely different operating systems, with different cores and different system calls. However, the compiler generates different code based on different platforms, allowing the binaries to run in a proprietary platform and implement the same functionality.
In short, C source code is cross-platform and compiled target files and executables are not cross-platform, cross-platform mainly rely on the compiler on each platform.
In the era of the use of assembly language, each manufacturer has its own assembly language, then the computer program and machine binding, not the same manufacturer's program in other manufacturers of the platform can not run. Until the C language appears, we can change the C language Program source files under the X86 platform to run directly after the power platform is compiled. Therefore, the cross-platform porting function of C refers to the portability of hardware architectures. The cross-platform capability of Java means that it does not need to specify that the operating system can run directly.
C Language "Write once, compile everywhere", Java is "compile once, run everywhere".
As C + + founder Sour, the JVM has created a new platform for all Java programs to run on this platform, while C and C + + code can run on dozens of different platforms, from this point of view, C and C + + are cross-platform, and Java is not.
The above content from Baidu know, I do record.
A brief discussion on "cross-platform"