in which language are definitions of built in functions like printf written...assembly or C?

m a bit confused...how can it b written in C coz again u will need a C compiler to compile it..
also if it is written in assembly..then how can the code run on different machines..i mean,assembly language would be different for different architectures,won't it..??

m a bit confused...how can it b written in C coz again u will need a C compiler to compile it..

Yeah, so? You compile C-version-6 with the compiler C-version-5 and you have an updated compiler.

also if it is written in assembly..then how can the code run on different machines..i mean,assembly language would be different for different architectures,won't it..??

If only standard C is written, the source can be built on different systems which makes them run on the architecture built on. For those things that are architecturally specific, like I/O, different code is written for each architecture.

m a bit confused...how can it b written in C coz again u will need a C compiler to compile it..
also if it is written in assembly..then how can the code run on different machines..i mean,assembly language would be different for different architectures,won't it..??

printf() is not a built-in function, but instead it is a library function, and all library functions are compiled with the C compiler. C compilers do not have any built-in "functions".

How library functions are written is up to whoever wrote the compiler, or is implementation dependent. Microsoft may write it in C language, but Borland might write it in assembly. Microsoft has actually done it both ways with various compilers.

Its true that assembly language functions restrict their use to only one architecture. Such fucntions have to be completly rewritten to port to others.

Edited 5 Years Ago by Ancient Dragon: n/a

Yeah, so? You compile C-version-6 with the compiler C-version-5 and you have an updated compiler.

And that's the Chick & Egg dilemma. What did K&R use the build the first C compiler (see the answer here)?

Edited 5 Years Ago by Ancient Dragon: n/a

Older "C" compilers actually converted "C" source to assembler source and then assembled and linked the code to create the final object.

This question has already been answered. Start a new discussion instead.