Platform Dependency in C Programming

Platform Dependency in C Language

In this article, I am going to give a brief about platform dependency in the C language, and why C applications are run on a single platform. Please read our previous article, where we discussed the different types of applications, we can develop using different programming languages.

Platform Dependency in C Language

Whenever we install C software, depending on the operating system we need to download and installed it. Let say we want to install C on Windows and Mac operating system. Windows understands .exe and MAC understands .dmg file. We also know that every application is a standalone application including programming languages. So, all the programming languages are stand-alone applications only. So, we need to download and installed it based on the operating system.

Whenever we install C, Compiler (to compile the application and generate machine code) + Library (to develop application) will be installed in the system. The Windows compiler will work for the Windows operating system only and the MAC compiler will work only for MAC operating system.

What is Platform Dependency?

Windows compiler will do a favor for Windows only and MAC compiler will do a favor for MAC system only. This is known as Platform Dependency. That means if we develop one application using Windows Operating System if that application can only be executed on Windows Operating System and can be run on other Operating Systems like Mac, Linux, this is called platform dependency. And the language used for developing such applications is called Platform Dependent language. C and C++ are platform-dependent languages.

What is Platform Dependency?

Consider one simple C program, just source code of addition of two numbers as shown below. Let name the program App.C.

Platform Dependency in C Language

Now we need to compile the above source code. Because as a developer we can understand the source code but the machine cannot the source code. What the machine understands is the compiled code. Nothing but binary instructions This source code will be passed to two different operating systems. Different operating system compilers will be working for respective OS.

  1. Windows: For Windows, the Windows Compiler will create the App.exe file. This App.exe file will work only on Windows OS and not on any other OS.
  2. Mac: For Mac, the Mac compiler will create an App.dmg file. This App.dmg file will work only on MAC OS and not on any other OS.

For better understanding, please have a look at the below diagram.

Platform Dependency in C
Follow Us On