Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   How gcc is compiling c program (http://www.go4expert.com/forums/gcc-compiling-c-program-t4807/)

sharmila 22Jun2007 12:41

How gcc is compiling c program
 
Hi all,
I read that gcc is written in C language and can compile itself. But I did not understand how it will happen.Can anyone explain me how can a program compile itself?

Regards,
sharmila

sharmila 22Jun2007 13:05

Re: How gcc is compiling c program
 
sorry.. my title is different.. how gcc is compiling itself?

DaWei 22Jun2007 15:35

Re: How gcc is compiling c program
 
Source code is source code. The compiler doesn't know or care.

sharmila 22Jun2007 19:01

Re: How gcc is compiling c program
 
http://www.network-theory.co.uk/docs...ccintro_5.html

In the link menctioned above, in 2nd para, there is a statement " GCC is written in C with a strong focus on portability, and can compile itself, so it can be adapted to new systems easily. "
what does this mean?

If we wrote a c-program, the compiler has to understand c-syntax, if the compiler itself is in C then how do it know which syntax it has to follow.

shabbir 22Jun2007 20:48

Re: How gcc is compiling c program
 
Its an incremental development. Say I have a language X (could be an assembly as well) where I write the initial stages of the compiler and then use that compiler to develop the program itself. Now the final C compiler of GCC is developed in C and it could so happen that the initial module is also advanced to the C language.

sharmila 25Jun2007 09:22

Re: How gcc is compiling c program
 
Thanks Shabbir..


All times are GMT +5.5. The time now is 15:11.