How gcc is compiling c program

Discussion in 'C' started by sharmila, Jun 22, 2007.

  1. sharmila

    sharmila New Member

    Joined:
    Mar 24, 2006
    Messages:
    75
    Likes Received:
    1
    Trophy Points:
    0
    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
     
  2. sharmila

    sharmila New Member

    Joined:
    Mar 24, 2006
    Messages:
    75
    Likes Received:
    1
    Trophy Points:
    0
    sorry.. my title is different.. how gcc is compiling itself?
     
  3. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    Source code is source code. The compiler doesn't know or care.
     
  4. sharmila

    sharmila New Member

    Joined:
    Mar 24, 2006
    Messages:
    75
    Likes Received:
    1
    Trophy Points:
    0
    http://www.network-theory.co.uk/docs/gccintro/gccintro_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.
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,341
    Likes Received:
    378
    Trophy Points:
    83
    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.
     
  6. sharmila

    sharmila New Member

    Joined:
    Mar 24, 2006
    Messages:
    75
    Likes Received:
    1
    Trophy Points:
    0
    Thanks Shabbir..
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice