Have examined process Creating program Have developed program Written in C Source code
|
|
- Aubrie Gardner
- 5 years ago
- Views:
Transcription
1 Preprocessing, Compiling, Assembling, and Linking Introduction In this lesson will examine Architecture of C program Introduce C preprocessor and preprocessor directives How to use preprocessor s directives to manage program Have examined process Creating program Have developed program Written in C Source code Next step Translate into something computer can use Called object code Things to think about along the way How to accommodate different Versions Called localization Features Targets - Machines Operating Systems The First Step Model the process Examine at three levels Each with increasing detail Start with top level Begin with source file End with object or machine code Also called object file or machine code file Machine code will be unique to specific computer or microprocessor Transformation from source to object Called compilation or compiling Top Level - 1 of 22 -
2 Level 1 Level 2: The Pieces Let s begin with preprocessor Preprocessor Simple and handy tool Its job is to process C source code Before compiler Reads source program - 2 of 22 -
3 Translates it into machine code Question might be Why do we have to do this Overview Many of useful features and capabilities of C Not implemented by compiler Rather Selected by user Brought in on demand by preprocessor When program written User includes various directives to preprocessor Preprocessor Reads source file Interprets directives Effects operations specified by directives directives tell the preprocessor Which library files to include Which user written files to include Which portions of the program to include or exclude We may want slightly different versions of program For different applications May want to conditionally include debug code Specify certain constant identifiers Called symbolic constants Make reading and managing program easier Structure From above discussion we see Preprocessor has Input C source code Containing embedded preprocessor directives Output Preprocessed C source file Input to compiler Implementation Separate Program - 3 of 22 -
4 Reads original C source file Looks for lines beginning with # symbol Evaluates each such line Writes out C source to compiler Based upon directives included in line Single Program Performs Preprocessing Compilation In single pass Preprocessor Language Preprocessor language specified as set of directives Directives typically begin in column 1 (caution) of source file Depends upon version of preprocessor As it goes through source file line by line Preprocessor looks for lines beginning with the special character # Syntax Completely independent of the C language Number of directives Approximately Shown in following table Preprocessor in Action Examine each line in program source Those that do not begin with # Viewed as source text These are ignored and sent directly to output Those that begin with # Expand Transform As directed by the command - 4 of 22 -
5 Assuming process runs correctly Must result in a C program Preprocessor does not correct User design errors Syntactic errors Grammatical errors Directive Definition #define #undef #include #if #ifdef #ifndef #elif #else #endif #line defined name defined(name) Define a preprocessor macro or symbolic constant Undefine or remove a preprocessor macro Insert contents of another source file Conditionally include contents of another source file Conditionally include contents of another source file if macro name is defined Conditionally include contents of another source file if macro name is not defined Conditionally include contents of another source file if macro name is defined and previous #if, #ifdef, #ifndef, or #elif failed Alternative action if preceding #if, #ifdef, #ifndef, or #elif directive fails Closes #if, #ifdef, #ifndef, or #elif construct Return line number for compiler message Directive that returns 1 if name is defined as preprocessor macro and 0 otherwise # operator Directive to replace macro parameter with string constant containing parameter s value ## operator Create single token from two adjacent tokens #pragma #error Specify proprietary information to the compiler Return a compile time error with associated message - 5 of 22 -
6 Lexical Conventions Line beginning with # Preprocessor command Name of command must follow # ISO C - International Standards Organization White space can precede or follow # on the same source line Older versions do not permit Line with only # ISO C Null directive Treated as blank line Older versions May be different Remainder of the line following the command May contain command args Args subject to macro replacement If no args required Remainder of line should be empty White space and comments allowed Often old compilers will ignore Preprocessor lines are recognized Before macro expansion Will talk about macros shortly If macro expands into something that looks like preprocessor directive Directive not recognized #define STRLIB #include<string.h> STRLIB 1. #define processed STRLIB is interpreted to mean #include<string.h> 2. STRLIB substitution executed Based upon the definition in previous line 3. Token sequence #include<string.h> passed to compiler as code - 6 of 22 -
7 The preprocessor recognizes the line continuation character Commands can extend to multiple lines with the \ character #define DOLLAR $ #define BACKSLASH \ #define MODULUS Results in 2 lines not 3 as might be expected Line 2 continued on to line 3 these interpreted as single line #define SWAP(a, b) { } a ^= b; \ b ^= a; \ a ^= b; \ Preprocessor Directives File Inclusion Directive #include Simplest preprocessor directive Has two forms syntax #include <filename> #include filename Either form Replaces the current line with Entire contents of the named file If complete path not given Search determined by form used < > Search in certain standard places System type places - 7 of 22 -
8 Determined by implementation Defined by search rules Specific location set at time of compiler installation First search some local places Current directory Second Certain standard places General intent < > Standard implementation files Programmer written files Included file May contain #include commands Number Implementation dependent ANSI C requires support for 8 minimum Error if included file cannot be found Third form of #include recognized syntax #include preprocessor tokens The tokens undergo normal macro expansion Result must match one of the first two forms #define COMMS G:/mySystem/include/comms.h #include COMMS Causes the preprocessor to look in directory and for the file specified G:/mySystem/include/comms.h Note: the forward slash / or back slash \ used to separate directories along a directory path depends upon operating system. Typically UNIX or LINUX derivatives use the forward slash and Windows derivatives use the back slash - 8 of 22 -
9 Macro Substitution Directives #define #undef syntax i. #define name text ii. #define name (arg 1, arg 2,... arg n,) text iii. #undef name #define i. The first form of #define directive Causes name To be defined as a macro to the preprocessor Instructs the preprocessor To replace all (unquoted) occurrences of name with text name Must be an identifier as defined by the C language U/L case letters... text Called the body of the macro Process called macro substitution Simple macros Common use Symbolic constants #define MAXSIZE 2048 #define PI 3.14 #define TWOPI 6.28 #define TWOPI (3.14*2.0) #define TWOPI (PI + PI) int myarray [MAXSIZE]; circumference = TWOPI * radius area = PI * pow(r,2); - 9 of 22 -
10 Macros with Parameters Second form of #define directive Declares a formal parameter list Parameter list Immediately follows macro name No intervening whitespace If whitespace Definition assumed to be macro with no args Enclosed in () Separated by commas Args in the parameter list Must be identifiers No two the same Need not be used in macro body Parameter list may be empty Using a Parameterized Macro Macro invoked Writing name Left parenthesis 1 actual arg for each formal parameter Separated by commas Right parenthesis If no formal parameters Must include empty arg list Whitespace may appear Between Name Left parenthesis Formal arg May contain Properly balanced parenthesis Commas If within set of parenthesis Braces and subscripting brackets Cannot contain commas Do not have to balance - 10 of 22 -
11 #define sum(x,y) ((x) + (y)) x = sum(2*a, b) / sum (c,d); x = sum(2 * g(a,b), h(a,b)) / sum (c,d); #define getmodem() getc(modemin) while ((c = getmodem())!= EOF) Can define a macro that takes arbitrary statement as its argument #define assign(anystatement) anystatement assign( {a = 1 ; b = 2;}) assign (c = 0; d = 1; e = 2;) #define max(a,b) ((A) > (B)? (A) : (B)) max (3, 4); max (6, 5); Potential problems Consider max(i++, j++); Appears to be simple use of max () Observe ((A) > (B)) replaced by ((i++) > (j++)) (A) : (B) replaced by ((i++) : (j++)) Potentially each variable is incremented twice #undef The #undef macro Companion to #define - 11 of 22 -
12 syntax #undef name Used to make name No longer defined Causes preprocessor to forget Macro definition of name Once name is undefined Can be given new definition Using #define Not an error To undefine a name that is not defined Macro expansion Not performed within #undef directive Conditional Compilation Directives #if #else, #elif #endif syntax #if constant-expression #else, #elif constant-expression #endif Conditional Compilation directives Based upon computed condition Allow lines of source code to be Passed through Eliminated Used to control the way the source code Assembled Compiled Semantics - 12 of 22 -
13 As expected #if constant-expression constant-expression Must evaluate to constant arithmetic value May include macro substitution if constant-expression non- zero Subsequent C code lines Intended to be included in program All C source lines Sent to preprocessor output Until #else, #elif, or #endif Expression encountered #else, #elif constant-expression #else Like familiar if - else If if previous conditions fail Lines follow #else are included #elif constant-expression Equivalent to else if Like if constant-expression evaluated Consequences are the same as #if #endif Closes the #if sequence Let the variable SYSTEM identify the host system LINUX OSX UNIX WIN7-13 of 22 -
14 Want different header file included depending upon system Each defines system specific information #if LINUX #define HDR linuxheader.h #elif OSX #define HDR osxheader.h #elif UNIX #define HDR unixheader.h #else #define HDR win7header.h Conditional Directives Directives #ifdef #ifndef syntax #ifdef name #ifndef name Conditional directives Test if an identifier Defined Not defined #ifdef Equivalent to if 1 if the identifier is defined if 0 if the identifier is not defined #ifndef Equivalent to if 0 if the identifier is defined if 1 if the identifier is not defined or undefined - 14 of 22 -
15 Want different debug code included depending upon system Conditionally include debug code Don t want to Include in the final version Take out For future upgrades Each defines system specific information #define LINUX 0 #define WIN7 0 #define UNIX 0 #define OSX 1 #if def LINUX #endif Linux debug code #if def WIN7 #endif Win 7 debug code #if def UNIX #endif Unix debug code #if def OSX #endif osx debug code Program Multiple files Several files share Common.h file May want to Debug separately Use for multiple targets Use for different programs In final build Will have multiple definitions for variable if.h file included multiple times - 15 of 22 -
16 May have added debug code to source For use during development Want to remove for release Bad style to individually comment out Each line of debug code Preprocessor can help preproc0.c #include <string.h> #include <stdio.h> #define DEBUG // commenting out this line will // prevent debug code from inclusion in final build int main() { char* mystring = "Hello"; #ifdef DEBUG #endif printf ("The string length is %d\n", strlen(mystring)); } return 0; Miscellaneous Directives Directives #line #error #pragma #line - 16 of 22 -
17 syntax #line line-number filename #line line-number If program built from Multiple other files Sometimes useful to annotate With line numbers from original file Instead of normal sequential numbering Info provided by #line directive Used to instantiate the LINE FILE LINE Line number of current source program Decimal integer constant FILE Name of current source file String constant preproc1.c #include <stdio.h> #include <string.h> int main() { char* mystring = "Hello"; #line 123 "myfile" printf ("This line is %d from %s\n", LINE, FILE ); printf ("The string length is %d\n", strlen(mystring)); return 0; } - 17 of 22 -
18 #error Used to write Compile time error message syntax #error error-message error-message is subject to macro expansion Typically used in conditionals Warn of inconsistencies Constraint violations Incomplete information preproc2.c #include <stdio.h> #include <string.h> #define SYSTEM Linux #ifndef SYSTEM #endif #error "You must specify the system type" int main() { } char* mystring = "Hello"; printf ("The string length is %d\n", strlen(mystring)); return 0; #pragma Used to Add new preprocessor or compiler functionality Provide implementation defined information to the compiler syntax #pragma tokens No restrictions on tokens Compilers should ignore what they do not understand - 18 of 22 -
19 args to directive Subject to macro expansion No agreement on standard pragmas #pragma pagesize (number of lines) MS Visual C++ Sets the number of lines desired per page of source listing #pragma pages (<pages>) Generate <pages> (formfeeds) in source listing Default value is 1 #pragma inline Compile with fast calling convention Typedef Names C provides facility for creating new data type names called typedef Typedef creates alias or synonym for existing type syntax typedef typename identifier After declaration identifier becomes synonym for typename Caution Typedef does not create a new type It is merely a synonym or alias for an existing type Cannot redefine the built-in meaning of a type typedef int double is illegal typedef int* INTPTR; INTPTR is not a pointer to an int It may be used where ever and int* can be used INTPTR myptr; myptr is now a pointer to an integer - 19 of 22 -
20 typedef Very useful in simplifying complicated declarations Thus Helps to simplify program Makes intent more obvious Use carefully Rather than clarify Overuse can serve to confuse The Compiler Compiler is a tool for translating programs Into variety of forms One such form Assembly language the instruction set for the machine As we saw in level 2 diagram above Top level program Can be made up of number of modules Module can be C source file Standard library file Defined as part of the language such as Math library String library Library that manages all input and output Custom library Under the Hood As program compiled Compiler has a lot of record keeping to do Translation Unit As compilation process proceeds Each.c or source file compiled individually Called translation unit Symbol Table As each source file compiled Table of identifiers of symbols within program created Called symbol table - 20 of 22 -
21 How compiler keeps track of All identifiers used Where in memory variables placed Allocate Memory Yes or No Each symbol name entered into symbol table Declaration brings name into name space No memory allocated Definition brings name into name space Sufficient memory allocated to hold variable If definition appears in different translation unit Identify as extern Want only single definition memory allocation For each variable or function body in system Prior to this stage Program did not depend upon machine Now program in form that will execute only on particular machine The Assembler Assembler is tool we use for converting Assembly language into machine language Program expressed as collection of 0 s and 1 s machine understands The Linker Although program now in machine language Not ready to be executed Problem All variables and data structures we use Must reside in computer memory Each needs an address in memory Question Which address should we use Unfortunately Cannot always use the same address What if someone else wants to use same address - 21 of 22 -
22 To solve problem assembler generates Relocatable code Code that can be placed anywhere in memory Second question arises at this time We d like to be able to use existing code Our own Other peoples How do we get this into our program without typing in each time Tool called linker loader can help with both problems Does two jobs 1. Links collection of program modules together 2. Resolves address problems Summary In this lesson examined Architecture of C program Introduced C preprocessor and preprocessor directives How to use preprocessors directives to manage program Should now be comfortable working with basic C preprocessor directives Know when and how to use Aware if tools compiler, assembler, and linker and role they play in building C program - 22 of 22 -
OBJECT ORIENTED PROGRAMMING USING C++
OBJECT ORIENTED PROGRAMMING USING C++ Chapter 17 - The Preprocessor Outline 17.1 Introduction 17.2 The #include Preprocessor Directive 17.3 The #define Preprocessor Directive: Symbolic Constants 17.4 The
More informationProgramming for Engineers C Preprocessor
Programming for Engineers C Preprocessor ICEN 200 Spring 2018 Prof. Dola Saha 1 C Preprocessor The C preprocessor executes before a program is compiled. Some actions it performs are the inclusion of other
More informationfpp: Fortran preprocessor March 9, 2009
fpp: Fortran preprocessor March 9, 2009 1 Name fpp the Fortran language preprocessor for the NAG Fortran compiler. 2 Usage fpp [option]... [input-file [output-file]] 3 Description fpp is the preprocessor
More informationChapter 7: Preprocessing Directives
Chapter 7: Preprocessing Directives Outline We will only cover these topics in Chapter 7, the remain ones are optional. Introduction Symbolic Constants and Macros Source File Inclusion Conditional Compilation
More informationA Fast Review of C Essentials Part II
A Fast Review of C Essentials Part II Structural Programming by Z. Cihan TAYSI Outline Macro processing Macro substitution Removing a macro definition Macros vs. functions Built-in macros Conditional compilation
More informationFeatures of C. Portable Procedural / Modular Structured Language Statically typed Middle level language
1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC
More informationUnit 4 Preprocessor Directives
1 What is pre-processor? The job of C preprocessor is to process the source code before it is passed to the compiler. Source Code (test.c) Pre-Processor Intermediate Code (test.i) Compiler The pre-processor
More informationErrors During Compilation and Execution Background Information
Errors During Compilation and Execution Background Information Preprocessor Directives and Compilation #define - defines a macro, identified by . During compilation, all instances of
More informationProblem Solving and 'C' Programming
Problem Solving and 'C' Programming Targeted at: Entry Level Trainees Session 15: Files and Preprocessor Directives/Pointers 2007, Cognizant Technology Solutions. All Rights Reserved. The information contained
More informationGabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming
1 2 CMPE 013/L Pre Processor Commands Gabriel Hugh Elkaim Spring 2013 3 Introduction Preprocessing Affect program preprocessing and execution Capabilities Inclusion of additional C source files Definition
More informationControl flow and string example. C and C++ Functions. Function type-system nasties. 2. Functions Preprocessor. Alastair R. Beresford.
Control flow and string example C and C++ 2. Functions Preprocessor Alastair R. Beresford University of Cambridge Lent Term 2007 #include char s[]="university of Cambridge Computer Laboratory";
More informationTopic 6: A Quick Intro To C
Topic 6: A Quick Intro To C Assumption: All of you know Java. Much of C syntax is the same. Also: Many of you have used C or C++. Goal for this topic: you can write & run a simple C program basic functions
More informationAppendix A. The Preprocessor
Appendix A The Preprocessor The preprocessor is that part of the compiler that performs various text manipulations on your program prior to the actual translation of your source code into object code.
More informationRule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.
Chapter 9: Rules Chapter 1:Style and Program Organization Rule 1-1: Organize programs for readability, just as you would expect an author to organize a book. Rule 1-2: Divide each module up into a public
More informationCSCI 171 Chapter Outlines
Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures
More informationC and C++ 2. Functions Preprocessor. Alan Mycroft
C and C++ 2. Functions Preprocessor Alan Mycroft University of Cambridge (heavily based on previous years notes thanks to Alastair Beresford and Andrew Moore) Michaelmas Term 2013 2014 1 / 1 Functions
More informationCS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco
CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level
More informationSlide Set 5. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary
Slide Set 5 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October 2016 ENCM 339 Fall 2016 Slide Set 5 slide 2/32
More informationMacros and Preprocessor. CGS 3460, Lecture 39 Apr 17, 2006 Hen-I Yang
Macros and Preprocessor CGS 3460, Lecture 39 Apr 17, 2006 Hen-I Yang Previously Operations on Linked list (Create and Insert) Agenda Linked List (More insert, lookup and delete) Preprocessor Linked List
More informationCOMP322 - Introduction to C++ Lecture 02 - Basics of C++
COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.
More informationAppendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.
A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators
More informationTopic 6: A Quick Intro To C. Reading. "goto Considered Harmful" History
Topic 6: A Quick Intro To C Reading Assumption: All of you know basic Java. Much of C syntax is the same. Also: Some of you have used C or C++. Goal for this topic: you can write & run a simple C program
More informationThe C Programming Language Guide for the Robot Course work Module
The C Programming Language Guide for the Robot Course work Module Eric Peasley 2018 v6.4 1 2 Table of Contents Variables...5 Assignments...6 Entering Numbers...6 Operators...7 Arithmetic Operators...7
More informationLanguage Design COMS W4115. Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science
Language Design COMS W4115 Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science Language Design Issues Syntax: how programs look Names and reserved words Instruction
More informationFull file at C How to Program, 6/e Multiple Choice Test Bank
2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)
More informationShould you know scanf and printf?
C-LANGUAGE INPUT & OUTPUT C-Language Output with printf Input with scanf and gets_s and Defensive Programming Copyright 2016 Dan McElroy Should you know scanf and printf? scanf is only useful in the C-language,
More informationConditional Compilation
Conditional Compilation printf() statements cab be inserted code for the purpose of displaying debug information during program testing. Once the program is debugged and accepted as "working'', it is desirable
More informationC for Engineers and Scientists: An Interpretive Approach. Chapter 7: Preprocessing Directives
Chapter 7: Preprocessing Directives Introduction Preprocessing Affect program preprocessing and execution Capabilities Inclusion of additional C source files Definition of symbolic constants and macros
More informationc) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.
2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C
More informationChapter 2. Lexical Elements & Operators
Chapter 2. Lexical Elements & Operators Byoung-Tak Zhang TA: Hanock Kwak Biointelligence Laboratory School of Computer Science and Engineering Seoul National Univertisy http://bi.snu.ac.kr The C System
More informationIntroduction to Programming in C Department of Computer Science and Engineering. Lecture No. #54. Organizing Code in multiple files
Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #54 Organizing Code in multiple files (Refer Slide Time: 00:09) In this lecture, let us look at one particular
More information3 PREPROCESSOR. Overview. Listing 3-0. Table 3-0.
3 PREPROCESSOR Listing 3-0. Table 3-0. Overview The preprocessor program (pp.exe) evaluates and processes preprocessor commands in your source files. With these commands, you direct the preprocessor to
More informationC Review. MaxMSP Developers Workshop Summer 2009 CNMAT
C Review MaxMSP Developers Workshop Summer 2009 CNMAT C Syntax Program control (loops, branches): Function calls Math: +, -, *, /, ++, -- Variables, types, structures, assignment Pointers and memory (***
More informationLESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:
LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words
More informationCompiler Design. Computer Science & Information Technology (CS) Rank under AIR 100
GATE- 2016-17 Postal Correspondence 1 Compiler Design Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts,
More informationA Fast Review of C Essentials Part I
A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types
More informationChapter 11 Introduction to Programming in C
C: A High-Level Language Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University Gives
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C C: A High-Level Language Gives symbolic names to values don t need to know which register or memory location Provides abstraction of underlying hardware operations
More informationCompiler, Assembler, and Linker
Compiler, Assembler, and Linker Minsoo Ryu Department of Computer Science and Engineering Hanyang University msryu@hanyang.ac.kr What is a Compilation? Preprocessor Compiler Assembler Linker Loader Contents
More informationCOSC121: Computer Systems: Runtime Stack
COSC121: Computer Systems: Runtime Stack Jeremy Bolton, PhD Assistant Teaching Professor Constructed using materials: - Patt and Patel Introduction to Computing Systems (2nd) - Patterson and Hennessy Computer
More informationCOSC 2P91. Bringing it all together... Week 4b. Brock University. Brock University (Week 4b) Bringing it all together... 1 / 22
COSC 2P91 Bringing it all together... Week 4b Brock University Brock University (Week 4b) Bringing it all together... 1 / 22 A note on practicality and program design... Writing a single, monolithic source
More informationprintf( Please enter another number: ); scanf( %d, &num2);
CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful
More informationCS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1. W hat are Keywords? Keywords are certain reserved words that have standard and pre-defined meaning in C. These keywords can be used only for their
More informationLESSON 4. The DATA TYPE char
LESSON 4 This lesson introduces some of the basic ideas involved in character processing. The lesson discusses how characters are stored and manipulated by the C language, how characters can be treated
More informationCS113: Lecture 7. Topics: The C Preprocessor. I/O, Streams, Files
CS113: Lecture 7 Topics: The C Preprocessor I/O, Streams, Files 1 Remember the name: Pre-processor Most commonly used features: #include, #define. Think of the preprocessor as processing the file so as
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More information1 Lexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler
More informationCOMP322 - Introduction to C++
COMP322 - Introduction to C++ Winter 2011 Lecture 2 - Language Basics Milena Scaccia School of Computer Science McGill University January 11, 2011 Course Web Tools Announcements, Lecture Notes, Assignments
More informationEL6483: Brief Overview of C Programming Language
EL6483: Brief Overview of C Programming Language EL6483 Spring 2016 EL6483 EL6483: Brief Overview of C Programming Language Spring 2016 1 / 30 Preprocessor macros, Syntax for comments Macro definitions
More informationProgramming for Engineers Introduction to C
Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines
More informationChapter 11 Introduction to Programming in C
C: A High-Level Language Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University! Gives
More informationComputer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary
GATE- 2016-17 Postal Correspondence 1 C-Programming Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts, Analysis
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University C: A High-Level Language! Gives
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified by Chris Wilcox, Yashwant Malaiya Colorado State University C: A High-Level Language
More informationINTRODUCTION 1 AND REVIEW
INTRODUTION 1 AND REVIEW hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Programming: Advanced Objectives You will learn: Program structure. Program statements. Datatypes. Pointers. Arrays. Structures.
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C C: A High-Level Language Gives symbolic names to values don t need to know which register or memory location Provides abstraction of underlying hardware operations
More informationLexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a
More informationChapter 2 Basic Elements of C++
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion
More informationLexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler
More informationCSE 374 Programming Concepts & Tools
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2017 Lecture 8 C: Miscellanea Control, Declarations, Preprocessor, printf/scanf 1 The story so far The low-level execution model of a process (one
More informationC Preprocessor. Prabhat Kumar Padhy
C Preprocessor Prabhat Kumar Padhy 1 C Preprocessor? Creating C program, Compiling and Runnings. Create using some editor Compilation gcc test.c (or) gcc o test test.c Running./test C Preprocessor The
More informationC: Program Structure. Department of Computer Science College of Engineering Boise State University. September 11, /13
Department of Computer Science College of Engineering Boise State University September 11, 2017 1/13 Scope Variables and functions are visible from the point they are defined until the end of the source
More informationThe C Pre Processor ECE2893. Lecture 18. ECE2893 The C Pre Processor Spring / 10
The C Pre Processor ECE2893 Lecture 18 ECE2893 The C Pre Processor Spring 2011 1 / 10 The C Pre Processor 1 The C pre processor is the very first step in any C or C++ program compilation. 2 It is a very
More informationOperator overloading
1 Introduction 2 The copy constructor 3 Operator Overloading 4 Eg 1: Adding two vectors 5 The -> operator 6 The this pointer 7 Overloading = 8 Unary operators 9 Overloading for the matrix class 10 The
More informationChapter 6: The C Preprocessor
C: Chapter6 Page 1 of 5 C Tutorial.......... The C preprocessor Chapter 6: The C Preprocessor AIDS TO CLEAR PROGRAMMING The preprocessor is a program that is executed just prior to the execution of the
More informationELEC 377 C Programming Tutorial. ELEC Operating Systems
ELE 377 Programming Tutorial Outline! Short Introduction! History & Memory Model of! ommon Errors I have seen over the years! Work through a linked list example on the board! - uses everything I talk about
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationLecture 05 I/O statements Printf, Scanf Simple statements, Compound statements
Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationC Syntax Out: 15 September, 1995
Burt Rosenberg Math 220/317: Programming II/Data Structures 1 C Syntax Out: 15 September, 1995 Constants. Integer such as 1, 0, 14, 0x0A. Characters such as A, B, \0. Strings such as "Hello World!\n",
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationCOMPILER DESIGN LECTURE NOTES
COMPILER DESIGN LECTURE NOTES UNIT -1 1.1 OVERVIEW OF LANGUAGE PROCESSING SYSTEM 1.2 Preprocessor A preprocessor produce input to compilers. They may perform the following functions. 1. Macro processing:
More informationUNIT - I. Introduction to C Programming. BY A. Vijay Bharath
UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been
More informationC++ Programming: From Problem Analysis to Program Design, Third Edition
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine
More informationPROGRAMMAZIONE I A.A. 2017/2018
PROGRAMMAZIONE I A.A. 2017/2018 STEPS OF GCC STEPS file.c Preprocessor Compiler file1.o file2.o Assembler Linker executable file PREPROCESSOR PREPROCESSOR The C preprocessor is a macro processor that is
More informationPRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILING
PRINCIPLES OF COMPILER DESIGN 2 MARKS UNIT I INTRODUCTION TO COMPILING 1. Define compiler? A compiler is a program that reads a program written in one language (source language) and translates it into
More informationLecture 4 CSE July 1992
Lecture 4 CSE 110 6 July 1992 1 More Operators C has many operators. Some of them, like +, are binary, which means that they require two operands, as in 4 + 5. Others are unary, which means they require
More informationEDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION
EDIABAS Electronic Diagnostic Basic System BEST/2 LANGUAGE DESCRIPTION VERSION 6b Copyright BMW AG, created by Softing AG BEST2SPC.DOC CONTENTS CONTENTS...2 1. INTRODUCTION TO BEST/2...5 2. TEXT CONVENTIONS...6
More informationModules:Context-Sensitive Keyword
Document Number: P0924r1 Date: 2018-11-21 To: SC22/WG21 EWG Reply to: Nathan Sidwell nathan@acm.org / nathans@fb.com Re: Merging Modules, p1103r2 Modules:Context-Sensitive Keyword Nathan Sidwell The new
More informationFundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials
Fundamentals We build up instructions from three types of materials Constants Expressions Fundamentals Constants are just that, they are values that don t change as our macros are executing Fundamentals
More informationModel Viva Questions for Programming in C lab
Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous
More informationAN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University
AN OVERVIEW OF C CSE 130: Introduction to Programming in C Stony Brook University WHY C? C is a programming lingua franca Millions of lines of C code exist Many other languages use C-like syntax C is portable
More information>B<82. 2Soft ware. C Language manual. Copyright COSMIC Software 1999, 2001 All rights reserved.
>B
More informationMotivation was to facilitate development of systems software, especially OS development.
A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.
More informationComputer Programming & Problem Solving ( CPPS ) Turbo C Programming For The PC (Revised Edition ) By Robert Lafore
Sir Syed University of Engineering and Technology. Computer ming & Problem Solving ( CPPS ) Functions Chapter No 1 Compiled By: Sir Syed University of Engineering & Technology Computer Engineering Department
More informationInformatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 5, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
More informationChapter 1 & 2 Introduction to C Language
1 Chapter 1 & 2 Introduction to C Language Copyright 2007 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 1 & 2 - Introduction to C Language 2 Outline 1.1 The History
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering
More informationFundamentals of Programming
Fundamentals of Programming Introduction to the C language Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) The C language
More informationWill introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators
Operators Overview Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operands and Operators Mathematical or logical relationships
More informationCS16 Week 2 Part 2. Kyle Dewey. Thursday, July 5, 12
CS16 Week 2 Part 2 Kyle Dewey Overview Type coercion and casting More on assignment Pre/post increment/decrement scanf Constants Math library Errors Type Coercion / Casting Last time... Data is internally
More informationThe Make Utility. Independent compilation. Large programs are difficult to maintain. Problem solved by breaking the program into separate files
The Make Utility Independent compilation Large programs are difficult to maintain Problem solved by breaking the program into separate files Different functions placed in different files The main function
More informationCOP 3275: Chapter 02. Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA
COP 3275: Chapter 02 Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA Program: Printing a Pun #include int main(void) { printf("to C, or not to C: that is the question.\n");
More informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationBasic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island
Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Data Types Basic Types Enumerated types The type void Derived types
More informationOur Strategy for Learning Fortran 90
Our Strategy for Learning Fortran 90 We want to consider some computational problems which build in complexity. evaluating an integral solving nonlinear equations vector/matrix operations fitting data
More informationME 461 C review Session Fall 2009 S. Keres
ME 461 C review Session Fall 2009 S. Keres DISCLAIMER: These notes are in no way intended to be a complete reference for the C programming material you will need for the class. They are intended to help
More informationBLM2031 Structured Programming. Zeyneb KURT
BLM2031 Structured Programming Zeyneb KURT 1 Contact Contact info office : D-219 e-mail zeynebkurt@gmail.com, zeyneb@ce.yildiz.edu.tr When to contact e-mail first, take an appointment What to expect help
More informationC Programming Review CSC 4320/6320
C Programming Review CSC 4320/6320 Overview Introduction C program Structure Keywords & C Types Input & Output Arrays Functions Pointers Structures LinkedList Dynamic Memory Allocation Macro Compile &
More informationLanguage Design COMS W4115. Prof. Stephen A. Edwards Fall 2006 Columbia University Department of Computer Science
Language Design COMS W4115 Katsushika Hokusai, In the Hollow of a Wave off the Coast at Kanagawa, 1827 Prof. Stephen A. Edwards Fall 2006 Columbia University Department of Computer Science Language Design
More information