-
is c platform independent?as i think it is.but it is compiler dependend.my statement is right or wrong?0
-
Member • Aug 5, 2012
Yes C is platform independent. However, it doesn't mean you can run any code on any machine. It depends on the resources you've used in the code but generally speaking, yes its platform independent.Are you sure? This action cannot be undone. -
Member • Aug 8, 2012
No C is not platform independent. Platform means Operating system + hardware and with the change of this combination you need different vendor specific programs to convert you c code into a machine executable code. So for windows you need a different program(compiler) but with Linux you need different compiler to convert your c code into machine executable code form. For each platform( operating system + hardware resources) you need different compiler programs to get executable code from c programs. That's why c is not platform independentAre you sure? This action cannot be undone. -
Member • Aug 8, 2012
No Sir,pawan.kumar123for windows you need a different program(compiler) but with Linux you need different compiler to convert your c code into machine executable code form
C is platform dependent , i accept.
But, Its difficult to say that "windows need different compiler than Linux to execute the program".
If you check out most of released compilers, 90% are 'em are compatible to both.
& The most popular one - GCC, GNU compiler is available for both Linux & Windows.
There are many more compilers available, some are with IDEs & some not. Some Compilers are maintained regularly & some not.
Maintained ones becomes popular & the out-of-date compilers become extinct.
For list of compilers :: <a href="https://en.wikipedia.org/wiki/List_of_compilers#C_compilers" target="_blank" rel="nofollow noopener noreferrer">List Of Compilers C Compilers</a>Are you sure? This action cannot be undone. -
Member • Aug 8, 2012
How you're saying that C language is platform dependent?
If you can make programs for Windows, Linux, AVR with same syntax and language constructs, using same compiler (GCC), then what is making it platform dependent?
True that you cannot directly port a windows program to Linux, but that doesn't mean its platform dependent.Are you sure? This action cannot be undone. -
Member • Aug 8, 2012
#-Link-Snipped-# No C language is not platform independent.
I think following points will give u good picture:
1) If you have written a code on one platform, then u need to compile the same
code on different platforms separately if want run your code on them.
2) Some internal library functions rely on the platform OS system calls
and may not work the same way on all platforms.
3) Also C language behaves differently on different platforms, for example
some architectures may follow different schemes for their data-path flow, different
little/big endian terminology.Are you sure? This action cannot be undone. -
Member • Aug 9, 2012
I think it is good discussable point that c is platform independent or not.I read in a book that c is portable.and portable means moovable.its true that on diffrent os it gives diffrent result but slightly diffrent.i think its platform independent.what u say?Are you sure? This action cannot be undone. -
Member • Aug 9, 2012
very well C is not suitable to be run on every machines.....sulochana anandis c platform independent?as i think it is.but it is compiler dependend.my statement is right or wrong?Are you sure? This action cannot be undone. -
Member • Aug 9, 2012
i just wan to ask did u check it?Are you sure? This action cannot be undone. -
Member • Aug 11, 2012
No I have read it on THE COMPUTER ACTIVE magazine an year agosulochana anandi just wan to ask did u check it?Are you sure? This action cannot be undone. -
Member • Mar 25, 2014
This discussion has gone all over the place now..sulochana anandI think it is good discussable point that c is platform independent or not.I read in a book that c is portable.and portable means moovable.its true that on diffrent os it gives diffrent result but slightly diffrent.i think its platform independent.what u say?
Here's my question––
If u write a C program using all the standard C libraries that are common to all platforms (Be it Unix(any flavor) or Windows)e.g--stdio.h or math.h or string.h or stdlib.h and so on..and compile it using a standard compiler (lets take gcc for this discussion's sake) and run it on any one standard CPU arch (X86 for instance 64 bit) why wouldn't the binary run across different machines matching all the above criteria? e.g when i compile a c code (making use of standard libraries--stdio,stdlib etc) using gcc on my mac (having X86 arch) and create a binary file, shouldn't it be capable of running the bin file on a linux or windows running on an X86 machine (same as my mac's) using the very same gcc runtime.. I'm not using any mac specific system calls (i use standard C libs) that would become unrecognized in a differing platform.. During the build process of this binary (comprising— preprocessing, compilation,generating assembly code which assembles into object code and then finally standard C built-in library .o files linking with the main.o) there has been no platform specific system calls or propreitary API used. What i'm getting at is that for building the C binary, i have used a common gcc compiler, a common microprocessor arch, and no platform specific system calls (e.g. including Linux's sys/io.h wouldn't even compile on any non linux based box let alone running it)Are you sure? This action cannot be undone. -
Member • Mar 25, 2014
So now getting back to query,, what is it that i'm missing?? Does the GCC runtime differ from OS to OS? Then the question is— what happens during when the C output file is being loaded in memory by the program loader part of the operating system? If there are certain platform runtime routines (dynamic libraries) that run on the specific machine when executing the output (post-build linking)... KEEP IN MIND.. ALL THRU THIS DISCUSSION WE HAVE BEEN TAKING INTO CONSIDERATION THE SAME CPU ARCHITECTURE..So pls don't say "it is due to differences in architecture"..RahulbsbThis discussion has gone all over the place now..
Here's my question––
If u write a C program using all the standard C libraries that are common to all platforms (Be it Unix(any flavor) or Windows)e.g--stdio.h or math.h or string.h or stdlib.h and so on..and compile it using a standard compiler (lets take gcc for this discussion's sake) and run it on any one standard CPU arch (X86 for instance 64 bit) why wouldn't the same binary run across different machines matching all the above criteria? e.g when i compile a c code (making use of standard libraries--stdio,stdlib etc) using gcc on my mac (having X86 arch) and create a binary file, shouldn't it be capable of running the bin file on a linux or windows running on an X86 machine (same as my mac's) using the very same gcc runtime.. I'm not using any mac specific C library function or routine that triggers Mac OS specific system calls (i use standard C libs—stdio.h or stdlib.h ) that would become unrecognized in a differing platform.. During the build process of this binary (comprising— preprocessing, compilation,generating assembly code which assembles into object code and then finally standard C built-in library .o files linking with my main.o) there has been no platform specific library used that would do any platform specific system calls or propreitary API used. What i'm getting at is that in order for building the C binary, i have used a common gcc compiler, a common microprocessor arch, and no platform specific system calls (e.g.#including Linux's sys/io.h in a C source file wouldn't even compile on any non linux based box let alone running it.. The compiler will throw a fit on Mac OS or Windows as it won't be able to locate and resolve sys/io.h )Are you sure? This action cannot be undone.