Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: c program
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 26144 of 26977
Post > Topic >>

Re: c program

by Chris H <chris@[EMAIL PROTECTED] > May 13, 2008 at 10:27 AM

In message 
<11fc6b6d-2276-45e0-9d53-bca2d0e04995@[EMAIL PROTECTED]
>, 
smarty <csmgsarma@[EMAIL PROTECTED]
> writes
>On May 10, 4:19 pm, sulekhaswe...@[EMAIL PROTECTED]
 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 p***** 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     /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
 




 5 Posts in Topic:
c program
sulekhasweety@[EMAIL PROT  2008-05-10 04:19:09 
Re: c program
pete <pfiland@[EMAIL P  2008-05-10 08:16:42 
Re: c program
Richard Heathfield <rj  2008-05-10 12:30:09 
Re: c program
smarty <csmgsarma@[EMA  2008-05-13 00:25:07 
Re: c program
Chris H <chris@[EMAIL   2008-05-13 10:27:52 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 3:52:22 CDT 2008.