Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > c program

Reply
Thread Tools

c program

 
 
sulekhasweety@gmail.com
Guest
Posts: n/a
 
      05-10-2008
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
 
Reply With Quote
 
 
 
 
smarty
Guest
Posts: n/a
 
      05-13-2008
On May 10, 4:19 pm, (E-Mail Removed) 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.
 
Reply With Quote
 
 
 
 
Chris H
Guest
Posts: n/a
 
      05-13-2008
In message
<(E-Mail Removed)>,
smarty <(E-Mail Removed)> writes
>On May 10, 4:19 pm, (E-Mail Removed) 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 /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to javac a java program w/ another java program which is w/o a main method cjeffwang@yahoo.com Java 1 10-31-2005 04:25 AM
System program/ Application program ?? Parvsandhu Java 2 07-11-2005 09:08 AM
how to convert a java program to an exe program ola Java 3 02-16-2004 09:42 AM
Calling Java program in another Java program Rey Java 4 12-12-2003 10:18 PM
passing data between Java program and C program--help pipi Java 1 07-21-2003 05:02 AM



Advertisments