c program

Discussion in 'C Programming' started by sulekhasweety@gmail.com, May 10, 2008.

  1. Guest

    Hi,

    can any one give a brief outline of the different stages in the
    execution of a C program , in terms of compilation, pre-processing,
    linking etc
    , May 10, 2008
    #1
    1. Advertising

  2. smarty Guest

    On May 10, 4:19 pm, wrote:
    > Hi,
    >
    > can any one give a brief outline of the different stages in the
    > execution of a C program , in terms of compilation, pre-processing,
    > linking etc


    1.the file u create in editor is saved as ".c" file
    2. this '.s' file is then PREPROCESSED for compilation .
    3. the preprocessed file undergoes compilation to generate a
    '.asm' (assembly file) or '.s' or '.src' file.
    4. this source file is assembled to generate a '.obj' file
    5. this .obj file is combined with other '.obj' or '.lib' files to
    generate an executable file.
    smarty, May 13, 2008
    #2
    1. Advertising

  3. Chris H Guest

    In message
    <>,
    smarty <> writes
    >On May 10, 4:19 pm, wrote:
    >> Hi,
    >>
    >> can any one give a brief outline of the different stages in the
    >> execution of a C program , in terms of compilation, pre-processing,
    >> linking etc

    >
    >1.the file u create in editor is saved as ".c" file
    >2. this '.s' file is then PREPROCESSED for compilation .
    >3. the preprocessed file undergoes compilation to generate a
    >'.asm' (assembly file) or '.s' or '.src' file.
    >4. this source file is assembled to generate a '.obj' file
    >5. this .obj file is combined with other '.obj' or '.lib' files to
    >generate an executable file.


    1 You write text (C source) in to a TEXT editor. Often the editor in an
    IDE

    2 You "Compile" the source.
    These days this will give you an object file for linking.
    Under the hood there are several steps

    2.1 The pre-processor does a *textual* replacement of macros and
    defines. This is why it is often required that macros have ( ) around
    them when they are defined.

    2.2 the now expanded text file is compiled. At one time this could be
    up to THREE passes and the command "CC file.c" actually fed file.c to a
    batch file called cc that called the three parts of the compiler. This
    would turn our assembler code in a text file. You then needed to
    assemble the text file to object code.

    Modern compilers are "single pass" which means they hide all the
    messing about and go from the source code text to object files in "one
    pass" and do not generate assembler code. Thus a separate assembler is
    not needed. In reality there is usually a pre-proccessor phase and the
    compiler will generate intermediate files and tables.

    These days there is more memory. In the Good old Days you use to have to
    swap floppy disks for compile, assemble and link phases :) (and 8inch
    floppies at that :))))

    3 linking. This links the various program object files and the library
    files

    linking needs to sort out all the extern function and data calls between
    modules and the library. It knits the modules together in one object
    file

    In some cases years ago where there is only a single file and no calls
    to the library the object file from the assembler or compiler could run
    without linking.

    The out put from the linker can be further processed to give S-Rec,
    Intel Hex or other files for downloading to eprom/flash programmers.

    --
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    Chris H, May 13, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pipi
    Replies:
    1
    Views:
    610
    Joseph Millar
    Jul 21, 2003
  2. Rey
    Replies:
    4
    Views:
    10,911
    Roedy Green
    Dec 12, 2003
  3. ola
    Replies:
    3
    Views:
    701
    Marco Schmidt
    Feb 16, 2004
  4. Parvsandhu
    Replies:
    2
    Views:
    406
    Thomas Weidenfeller
    Jul 11, 2005
  5. Replies:
    1
    Views:
    507
    Andrew Thompson
    Oct 31, 2005
Loading...

Share This Page