CrazyEngineers Archive
Old, but evergreen and popular discussions on CrazyEngineers, presented to you in read-only mode.
@sulochana anand • 05 Aug, 2012
is c platform independent?as i think it is.but it is compiler dependend.my statement is right or wrong?
@[Prototype] • 05 Aug, 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.
@pawan.kumar123 • 08 Aug, 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 independent
@Abhishek Rawal • 08 Aug, 2012
pawan.kumar123
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
No Sir,
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 :: Click Here
@[Prototype] • 09 Aug, 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.
@greatcoder • 09 Aug, 2012 sulochana anand 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.
@sulochana anand • 09 Aug, 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?
@Sreejith T • 10 Aug, 2012
sulochana anand
is c platform independent?as i think it is.but it is compiler dependend.my statement is right or wrong?
very well C is not suitable to be run on every machines.....
@sulochana anand • 10 Aug, 2012 i just wan to ask did u check it?
@Sreejith T • 11 Aug, 2012
sulochana anand
i just wan to ask did u check it?
No I have read it on THE COMPUTER ACTIVE magazine an year ago
@Rahulbsb • 25 Mar, 2014
sulochana anand
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?
This 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 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)
@Rahulbsb • 25 Mar, 2014
Rahulbsb
This 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 )
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"..
8k views

Related Posts

@mohan kuman · May 13, 2012

what are the functions of head regulator ,cross regulator
4.1k views

@Ankita Katdare · Aug 2, 2011

The Graduate Record Examinations (GRE) test is to measures verbal reasoning, quantitative reasoning, and critical thinking and analytical writing skills. Tests gauge undergraduate achievement in 8 specific fields of study...
23.6k views

@kashmirihasan · Jul 12, 2013

How to make a pure sine wave ups ??? any circuit diagram? and what is the difference between a pure sine wave ups and modified sine wave?
7.6k views

@Kaustubh Katdare · Mar 7, 2011

CEans, Micromax mobile literally took the Indian mobile market by storm by introducing the cheaper dual SIM mobiles. With heavy advertising and offering lot of cool features in their handsets...
9.6k views

@sumanth arisetty · Oct 27, 2013

hello pple.. im a mechanical engineering fresher.. ive tried many jobs and tired.. i wanted to start up my small scale industry in mechanical field.. please suggest me some product...
9.6k views