Programming In C++ Spring Semester 2013 Lecture 11 Programming In C++, Lecture 11 By Umer Rana.

Slides:



Advertisements
Similar presentations
Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 4 Modular Programming with Functions.
Advertisements

CSE 105 Structured Programming Language (C)
CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
Compilation and Debugging 101. Compilation in C/C++ hello.c Preprocessor Compiler stdio.h tmpXQ.i (C code) hello.o (object file)
User Defined Functions
Programming In C++ Spring Semester 2013 Practice 1-3 Lectures Programming In C++, Lecture 3 By Umer Rana.
Programming In C++ Spring Semester 2013 Lecture 12 Programming In C++, Lecture 12 By Umer Rana.
Programming In C++ Spring Semester 2013 Practice 2 Programming In C++, Practice By Umer Rana.
Programming In C++ Spring Semester 2013 Lecture 3 Programming In C++, Lecture 3 By Umer Rana.
Programming In C++ Spring Semester 2013 Programming In C++, Lecture 1
C Language.
Spring Semester 2013 Lecture 5
Programming In C++ Spring Semester 2013 Lecture 4 Programming In C++, Lecture 3 By Umer Rana.
Programming In C++ Spring Semester 2013 Lecture 13 Programming In C++, Lecture 13 By Umer Rana.
Week 4 – Functions Introduction. Functions: Purpose Breaking a large problem into a series of smaller problems is a common problem- solving technique.
Programming In C++ Spring Semester 2013 Lecture 8 Programming In C++, Lecture 8 By Umer Rana.
CSE 303 Lecture 16 Multi-file (larger) programs
Programming III SPRING 2015 School of Computer and Information Sciences Francisco R. Ortega, Ph.D. McKnight Fellow and GAANN Fellow LECTURE #3 Control.
Programming In C++ Spring Semester 2013 Lecture 2 Programming In C++, Lecture 2.
Separate compilation Large programs are generally separated into multiple files, e.g. tuples.h, ray.h, ray.c, tuples.c main.c With several files, we can.
Writing and Testing Programs Drivers and Stubs Supplement to text.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Software Language Levels Machine Language (Binary) Assembly Language –Assembler converts Assembly into machine High Level Languages (C, Perl, Shell)
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction.
Guide To UNIX Using Linux Third Edition
 2000 Prentice Hall, Inc. All rights reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction 13.2The #include Preprocessor Directive 13.3The.
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 12 - The Preprocessor Directives (Macros)
Macros. There are three basic phases for C programming. preprocessing, compiling, and linking. C input file is first passed to a preprocessing program.
Lecture-1 Compilation process
Introduction to C Programming CE Lecture 7 Compiler options and makefiles.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
Computer Programming I Hour 2 - Writing Your First C Program.
C Hints and Tips The preprocessor and other fun toys.
C Tutorial - Program Organization CS Introduction to Operating Systems.
Engineering Computing I Chapter 4 Functions and Program Structure.
1 Remember: Examination is a chance not ability. By ILTAF MEHDI, IT LECTURER, MIHE, KATR-E-PARWAN BRANCH, KABUL.
CSE 251 Dr. Charles B. Owen Programming in C1 Compilation and Makefiles.
DOCUMENTATION SECTION GLOBAL DECLARATION SECTION
Agenda Computer Languages How to Write a Simple C Program
15. WRITING LARGE PROGRAMS. Source Files A program may be divided into any number of source files. Source files have the extension.c by convention. Source.
Compiler Directives. The C Preprocessor u The C preprocessor (cpp) changes your source code based on instructions, or preprocessor directives, embedded.
EEL 3801 C++ as an Enhancement of C. EEL 3801 – Lotzi Bölöni Comments  Can be done with // at the start of the commented line.  The end-of-line terminates.
Separating Class Specification tMyn1 Separating Class Specification from Implementation Usually class declarations are stored in their own header files.
Multiple File Compilation and linking By Bhumik Sapara.
© Oxford University Press All rights reserved. CHAPTER 10 THE PREPROCESSOR DIRECTIVE.
C PREPROCESSOR. Introduction  It is a program that processes our source program before it is passed to the compiler.  Preprocessor commands (often known.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
C Programming Lecture 3 : C Introduction 1 Lecture notes : courtesy of Woo Kyun and Chang Byung-Mo.
Pre-Compiler Directives for TTCN-3 Ina Schieferdecker in response to CR5089 and 5090.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
2.1 First C Program. First Program Open visual studio, click new file Save as “programName.c” – Program must start with letter and have no spaces – Must.
CSC201: Computer Programming
Chapter 13 - The Preprocessor
Functions Separate Compilation
©2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Pre-processor Directives
2011/11/20: Lecture 15 CMSC 104, Section 4 Richard Chang
Programming Languages
Introduction to Programming
User Defined Functions
Preprocessor.
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
In C Programming Language
C Programming Language
Chapter 11: The Preprocessor
Assignment Operators Topics Increment and Decrement Operators
Compiler vs linker The compiler translates one .c file into a .o file
CPS125.
Presentation transcript:

Programming In C++ Spring Semester 2013 Lecture 11 Programming In C++, Lecture 11 By Umer Rana

Larger Programs Programming In C++, Lecture 11 By Umer Rana Separate Compilation These files can be written, compiled separately and then linked together to form the final executable program. e.g. void main() { int a,b, ans; printf(“Type two integers\n”); scanf(“%d %d”, &a,&b); ans= formula(a,b); printf(“Total of two integers are: %d”, ans); }

Larger Programs Programming In C++, Lecture 11 By Umer Rana Separate Compilation These files can be written, compiled separately and then linked together to form the final executable program. e.g. int formula(int x, int y) { return (x*x + y*y); }

Project Features Programming In C++, Lecture 11 By Umer Rana The Process can either be done “by hand”, by typing command-line messages to compile each source file and to link them together or process can be turned over to a Make utility. Make is a program that automates the compiling and linking process. When we have a large program with dozen source files we need to compile each one, then link the resulting.obj files to create a final exe.file. If we change the source file, we need to recompile it and relink everything, but no need to recompile these file that haven’t changed.it is difficult to keep track of which have been compile since the last link and which haven't

Project Features Programming In C++, Lecture 11 By Umer Rana Make utility keeps track of which source files must be recompiled to produce the final exe file. Make utility automates the whole compile and link process, so that one command suffices to perform all the steps necessary to generate the final exe file.

Advantages of Separate Compilation Programming In C++, Lecture 11 By Umer Rana Compile time is proportional to the size of the file being compiled so minimize compile time. Programming compile only those parts of a program that have been changed since the last compilation. Already working & debugged are not recompile. New file is compiled and linked with the previously compiled files. Enables to programmers to write well-structured modular programs. Separate compilation allows programmer to use library files.

Conditional Compilation Programming In C++, Lecture 11 By Umer Rana The useful facility provided by the pre-processor is conditional compilation The C preprocessor provides a better alternative, namely conditional compilation. Lines of source code that may be sometimes desired in the program and other times not, are surrounded by #if, # defined, #endif directive pairs as follows:

Conditional Compilation Programming In C++, Lecture 11 By Umer Rana #define TIMER int main () { int j,k; #if defined(TIMER) printf("Starting Test\n"); #endif #if defined(TIMER) printf("Ending Test\n"); #else printf("Done\n"); #endif getch(); }

Conditional Compilation Programming In C++, Lecture 11 By Umer Rana #undef Directive This #undef Directive cancels the action of a previous #define Directive. This Directive to make conditional compilation specific to certain sections of the program. Another use for #undef is to “turn off” macros that you have previously defined with a #define directive. e.g. #define TEST #undef TEST