csc1254lect05 - CSc 1254: Lecture # 5 Code Organization,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSc 1254: Lecture # 5 Code Organization, Templates & Exception September 21, 2005 Code Organization The C++ Compilation Mode Compiling Multiple Source Files Introduction to Templates Exception 1 Code Organization Well-organized C programs normally use multiple source and header files. They usually consist of libraries that handle various tasks. Each library performs a set of related tasks. A library can be used in a program by including its header file. C intrinsic library files are included between < > while user-defined (personal) library files are included between . #include <intrinsic_library_name> #include "user-defined_library_name.h" How the files are structured: header files (.h) a. public function prototypes b. public global variable declarations c. #define preprocessor commands 1 d. public struct and class declarations/typedefs source files (.cpp) a. private function prototypes b. function definitions for both public and private functions c. global variables d. private struct and class declarations/typedefs 2 Compilation Model The compilation process involves several steps. In the preprocessing phase comments are removed from the source file and special preprocessor directives are interpreted. During the compilation phase the C++ compiler translates source code to assembly code. The source code is received from the prepro- cessor. In the assembly phase object code is created. On a UNIX system you may see files with a .o suffix to indicate object code files. Finally, in the linking phase if a source file references library functions or functions defined in other source files the link editor combines these functions with the main function to create an executable file. External variable references are resolved during this phase also. (See diagram.) 3 Compiling Multiple Source Files When using the GNU g++ compiler, there are several flags that may be used....
View Full Document

This note was uploaded on 01/17/2012 for the course CSC 1254 taught by Professor Blanks,l during the Fall '08 term at LSU.

Page1 / 9

csc1254lect05 - CSc 1254: Lecture # 5 Code Organization,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online