Chapter Summary

 < Day Day Up > 

The operating system interface to C programs and a variety of software development tools make the Linux system well suited to programming in C. The C libraries provide general-purpose C functions that make operating system services and other functionality available to C programmers. The standard C library libc is always accessible to C programs, and you can specify other libraries by using the l option to the gcc compiler.

You can write a C program using a text editor, such as vim or emacs. C programs always have a function named main and often include several other functions. Preprocessor directives define symbolic constants and macros and instruct the preprocessor to include header files.

gcc

When you use gcc, it calls the C preprocessor followed by the C compiler and the assembler. The compiler creates assembly language code, which the assembler uses to create object modules. The linker combines these object modules into an executable file. You can use the Wall option to gcc to detect risky constructs ones that are legal but suggest the possibility of later problems. Other options to gcc can help locate areas of your code that might not be portable.

gdb

Although using printf statements and the Wall option can help in tracking program bugs, it is a good practice to compile C programs routinely with the g option. This option causes information that can be interpreted by gdb, a symbolic debugger, to be generated as part of the executable file. When you run a program under the control of gdb, you can specify points where you want gdb to pause the program, inquire about the values of variables, display the program stack, and use a wide range of commands to learn about many other aspects of the program's behavior.

make

The make utility uses a file named Makefile (or makefile) that documents the relationships among files. It determines which modules of a program are out-of-date and compiles files to keep all modules up-to-date. The dependency line, which specifies the exact dependency relationship between target and prerequisite files, is the key to the operation of a makefile. Following the dependency line are construction commands that can bring the target up-to-date. Implied dependencies, construction commands, and the make macro facility are available to simplify the writing of complex makefiles.

The Linux system includes utilities that assist in keeping track of groups of files that undergo multiple revisions, often at the hands of multiple developers. These source code management systems include CVS, the Concurrent Versions System. CVS is built on top of RCS but provides a much more extensive set of operations for managing directories of files that may be accessed and modified by many users. It is a good choice for large-scale projects and for maintaining software releases that are sent to and from other sites.

     < Day Day Up > 


    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    ISBN: 131478230
    EAN: N/A
    Year: 2005
    Pages: 213

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net