Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
C Programming in Unix

C Programming in Unix



|Views: 7,900|Likes:
Published by Watsh Rajneesh
Advanced C Programming in the Unix environment.
Advanced C Programming in the Unix environment.

More info:

Published by: Watsh Rajneesh on Sep 09, 2007
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





Unix/C Notes
 Compiled by: 
Watsh Rajneesh
 Software Engineer @ Quark (R&D Labs) wrajneesh@bigfoot.com 
There is no warranty, either expressed or implied, with respect to the code contained onthis page, it's quality, performance, or fitness for any particular purpose. All code isoffered "as is". I am not responsible for what you do with the code (or what the code doesto you). In other words, you're on your own ...
 1.http://www.yendor.com/programming/unix/apue/app-c.html-- Solutions to RichardStevens' masterpiece on Advanced Programming in Unix Environment.2.http://www.cs.cf.ac.uk/Dave/C/CE.html-- Good C programming (for UNIX OS)reference.3.http://www.erlenstar.demon.co.uk/unix/faq_toc.html-- Unix FAQ.
1. C Programming in Unix environment
 The figure above shows the
C compilation model.
-- The Preprocessor accepts source code as input and is responsible for removing comments and interpreting special preprocessor directives denoted by #.
C Compiler
-- translates source to assembly.
-- creates object code.
Link Editor
-- If a source file references library functions or functions defined inother source files the link editor combines these functions (with main()) to create anexecutable file. External Variable references resolved here also.Useful
compiler options
:gcc [option | filename]...g++ [option | filename]...
: Disable linking. Later all the object files can be linked as,gcc file1.o file2.o ...... -o executable
library : Link with object libraries.gcc calc.c -o calc -lm
directory : Add directory to the list of directories containing object-library routines.Thelinker always looks for standard and other system libraries in /lib and /usr/lib. If you wantto link in libraries that you have created or installed yourself (unless you have certain privileges and get the libraries installed in
) you will have to specify where you
files are stored, for example:gcc prog.c -L/home/myname/mylibs mylib.a
 pathname : Add pathname to the list of directories in which to search for #include fileswith relative filenames (not beginning with slash /).BY default, The preprocessor first searches for #include files in the directory containingsource file, then in directories named with -I options (if any), and finally, in
.So to include header files stored in /home/myname/myheaders you would do:gcc prog.c -I/home/myname/myheaders Note: System library header files are stored in a special place (/usr/include) and are notaffected by the -I option. System header files and user header files are included in aslightly different manner 
: invoke debugging option. This instructs the compiler to produce additional symboltable information that is used by a variety of debugging utilities.
: define symbols either as identifiers (-Didentifer) or as values (-Dsymbol=value) in asimilar fashion as the #define preprocessor command.Explore the libraries to see what each contains by running the command
ar t
libfile.man 3 ctime -- section 3 of the unix manual contains documentation of the standard clibrary functions.cat <filename> | more -- view a file.
2. Advanced C topics
 Some useful tables for C Programming are given below:

Activity (66)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
ganesh_krishna added this note
nndhnim liked this
nickwearby liked this
aamun liked this
FidoDido2013 liked this
vel.sakthi3152 liked this
Said Aydogan liked this
Raj Kamal liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->