Overview of C++ Support in TI Compiler Tools July 2008

Size: px
Start display at page:

Download "Overview of C++ Support in TI Compiler Tools July 2008"

Transcription

1 Overview of C++ Support in TI Compiler Tools July Table of Contents 1 Table of Contents Introduction Support for the Language Embedded C Some Comments on Efficiency Exceptions and RTTI Exceptions on ARM Support for the Library ARM v4.4.x C++ Library Problem Name Mangling Implementing XDAIS Algorithms in C BIOS and C Introduction This document describes the state of the C++ support in TI compiler tools as of these compiler versions: Target Version C6000 v6.1.0 ARM v4.5.0 C5500 v4.2.0 MSP430 v3.0.0 C2000 v Support for the Language Support for the language is excellent. There are no major gaps. 4 Embedded C++ Embedded C++ is a subset of the C++ language aimed at embedded systems. It got its start from a group of semiconductor companies in Japan in the mid-90's. It is a pure subset of C++, with a few very minor differences in the library. The general idea of embedded C++ is to keep most of the features of C++ which support object oriented programming, but leave out or make optional those features with undue performance impact. For more information visit the Embedded C++ home page. Support for embedded C++ is in the form of the compiler option -pe. This option makes it illegal to use any C++ feature that is not in embedded C++. Embedded C++ omits these C++ features:

2 - Templates - Exceptions - Run-time type information (RTTI) - The new cast syntax - The keyword mutable - Multiple inheritance - Virtual inheritance Note Embedded C++ disallows templates. This means you can use very few of the features in the C++ portion of the RTS library. 5 Some Comments on Efficiency This is a rather broad topic that likely merits a separate document. This section covers a few highlights. No aspect of C++ inefficiency is unique to TI compilers. These aspects are common to all C++ compilers. This means you can consult any number of existing books, training courses, web pages, etc. on this topic to learn more about it. C++ Language Feature EC++ Subset Performance Penalty Classes Yes No Overloading Yes No Operator Overloading Yes No Inheritance (derived classes) Yes No Polymorphism (virtual functions) Yes Only when used Wide Character Support Yes No Multiple Inheritance No No Virtual Base Classes No Only when used Templates No No Exceptions No Severe, even if not used (1) Namespaces No No Run-time Type Identification (RTTI) No Yes, even if not used Dynamic Casts No Only when used Note (1): More detail in the next 2 sections Be careful, though. Sometimes even those no performance penalty features can end up costing you. These books have some great examples: - Effective C++, Scott Meyers - More Effective C++, Scott Meyers C++ is a powerful tool. It can be powerfully applied for both good and bad. A chainsaw is a decent analogy. Used well, you get the job done quickly and efficiently. Used poorly, the results can be tragic.

3 Do not think that Embedded C++ code is always more efficient. Even the C++ features allowed by Embedded C++ can be used poorly, with ill effect. The bad news is you have to understand the efficiency aspects of the C++ code you write. The good news is you can learn about those efficiency aspects from any number of sources that are available to you right now. 6 Exceptions and RTTI Support for exceptions and run-time type identification (RTTI) is disabled by default. Use command line options to enable them. - For exceptions: --exceptions - For RTTI: --rtti If any C++ code is built with one of those options, then all of it must be built that way, including libraries. Using exceptions also requires you to link with a special version of the compiler runtime support library. For example, when building for a C6400 device, use rts6400_eh.lib instead of rts6400.lib. Note eh stands for exception handling. Support for debugging exceptions is lacking. If an exception is thrown while you are debugging, you won t get lost with respect to where you are in the code. But you will not be able to determine, via debugger queries of one sort or another, the type or the value of the exception itself. Exceptions are costly in both cycles and code size, regardless of whether any exceptions are ever thrown. However, things are a bit different for the ARM compiler. 7 Exceptions on ARM When building with the older TIABI and default TI_ARM9_ABI, the ARM compiler exceptions perform as described in the previous section. When building with the new EABI, however, exceptions are implemented with a different method that imposes no cycle count penalty, though it does impose a memory size penalty. EABI stands for Embedded Application Binary Interface. A web search on EABI yields several useful links that describe ABI s generally, and the EABI in particular. You can also consult the document TMS470 EABI Migration supplied in the \docs directory of the ARM compiler release. Code built with --abi=eabi --exceptions uses a method of exception handling that imposes no cycle count overhead, provided no exceptions are thrown. When an exception is thrown, exception handling tables are indexed with the program counter to handle the exception. These tables can require lots of memory. Thus, exceptions are not enabled by default. Since these tables are not referenced during ordinary system execution, it makes sense to

4 allocate them to cheaper memory. Exactly how the tables are built and used are beyond the scope of this document. But, at the end of the final link, they are contained in two separate sections: ARM.extab and ARM.exidx. Lines similar to these in your link command file place these sections in cheaper memory..arm.extab > CHEAP_MEMORY.ARM.exidx > CHEAP_MEMORY This form of exception handling also requires that all of the code, including libraries, be built with exceptions enabled. The RTS library you link with must have _eh in the name. Note if you rely on the new linker ability to choose the RTS library for you, then this detail is taken care of automatically. EABI support is being added to other TI compilers. These compilers, too, will support table driven exception handling when building under EABI. 8 Support for the Library C++ library support, as of the above releases, is excellent. TI compilers supply a full implementation of the C++ library, including the STL. The C++ additions to the library are obtained from Dinkumware, a world class supplier of C++ libraries. There are some minor limitations regarding wide char support. Refer to the readme files and compiler documentation for more details. 9 ARM v4.4.x C++ Library Problem The C++ RTS libraries supplied with the ARM compiler v4.4.x have a problem that is corrected in v If the final link uses the Dinkumware library (named lib_something.a), then all of the C and C++ code linked into the system must be built against the Dinkumware header files that only come with a v4.4.x release. In particular, this means any outside vendor libraries must be rebuilt. This section refers to two different RTS library implementations: the TI implementation and the Dinkumware implementation. The TI library is the same one that always been released with the compiler. The Dinkumware (aka Dinkum) library is new. It contains all the new C++ library functionality. The header files you build with and RTS the library you link with must match. Consider, for example, the isspace function from the header file <ctype.h>. That function takes a single character as input and returns a boolean value which indicates whether that character is whitespace or not. The isspace function (like all the other character test functions) is implemented with a table lookup. Something like this: return char_props_table[char_under_test] & SPACE_FLAG; Details such as the exact name of the table used in the lookup are in the header file <ctype.h>. Those details are different between the TI and Dinkum libraries. The table

5 itself is declared in object code that comes from the library. Thus, usage of the TI library header file <ctype.h> means you must link with a TI RTS library. The same is true of the Dinkum library. Observant readers may note that you aren t necessarily in trouble yet. The code that executes that return statement comes from the same library that defines the table. True enough. However, if you build with optimization (-o2 or higher) then the isspace function is inlined, and then a direct reference to the character properties table does get compiled into user code. And thus the name of the table in user code and the name of the table that comes from the RTS object library must match. This problem only exists in the ARM compiler v4.4.x releases. None of the other TI compilers have this problem. 10 Name Mangling Name mangling is a detail of how C++ code is built. It is a detail which must be understood to be able to combine C++ code with other code. Examples of other code include C, assembly, XDAIS algorithms (which can only be in C), BIOS, etc. This section explains why name mangling is necessary and how to deal with it. One feature of C++ is called function overloading. This feature allows you to provide different implementations of the same function that can operate on different arguments. typedef class complex { } cx; cx cx_add(cx op1, cx op2); cx cx_add(int op1, cx op2); cx cx_add(cx op1, int op2); Support for this feature is implemented by what is called name mangling. The names of the functions are mangled to guarantee uniqueness. The mangling takes into account the function name, type and number of arguments, as well as the return type. For example, the mangled name of the first function above is _cx_add F7complexT1. The algorithm for name mangling is quite complicated, and generally impossible to duplicate manually. Rather than attempt that, use the C linkage convention to defeat the name mangling. The syntax can be applied to a single function declaration: extern C void func(int arg); Or to a group of function declarations: extern C { void func1(int arg); void func2(int arg); // linkage block

6 }... Functions declared extern C are not subject to name mangling. They are converted to assembly names by using the C compiler convention of prepending an underscore. For example, func1 becomes _func1. Note, however, even the C compiler convention for how C variable and function names are converted to assembly names is different under EABI. Under EABI, the name is func1 in both C and assembly code. Note other code can be in the linkage block, but only the function declarations are affected. Such declarations are normally placed in a header file that is then included any place those functions are defined or called. For a header file that can be shared between C++ and C code, that typically looks like #ifdef cplusplus extern C { #endif // Standard C code here #ifdef cplusplus } #endif Note the special name cplusplus is automatically defined when building with any C++ compiler. On a related note: If you are looking at mangled names in assembly, map files, etc. that came from C++ code, you can use the C++ Demangler tool to convert the mangled names into how they look in C++. The C6000 tool, for instance, is named dem6x. Consult your compiler User s Guide for more detail. 11 Implementing XDAIS Algorithms in C++ The XDAIS standard was developed to be object-based (usage of handles to create instances of algorithms) but not object oriented. For example IALG, used for memory requests abstraction, is a C interface. At present, XDAIS algorithms can be invoked from a C++ application, but cannot be developed and supplied via C BIOS and C++ BIOS is implemented as a combination of C and assembly code. Any C++ function called from BIOS code has to be declared with the extern C linkage convention. This includes functions referred to in gconf or tconf BIOS configurations. For more detail, see the Name Mangling section above.

7 BIOS header files can be used in C++ code because they use the #ifdef cplusplus #endif technique described in the Name Mangling section. Additional details on using BIOS with C++ can be found in section 2.8 of the BIOS User s Guide. For instance, the new and delete operators are implemented with MEM_alloc and MEM_free in order to support reentrancy. A BIOS C++ example using classes and member functions is available. See the bigtime example supplied with Code Composer Studio. It can be found in the directory: CCS_install_root\bios_version\packages\ti\bios\examples\bas ic\bigtime.

Exception Namespaces C Interoperability Templates. More C++ David Chisnall. March 17, 2011

Exception Namespaces C Interoperability Templates. More C++ David Chisnall. March 17, 2011 More C++ David Chisnall March 17, 2011 Exceptions A more fashionable goto Provides a second way of sending an error condition up the stack until it can be handled Lets intervening stack frames ignore errors

More information

QUIZ. What are 3 differences between C and C++ const variables?

QUIZ. What are 3 differences between C and C++ const variables? QUIZ What are 3 differences between C and C++ const variables? Solution QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Solution The C/C++ preprocessor substitutes mechanically,

More information

Object Oriented Design

Object Oriented Design Object Oriented Design Chapter 6 Example Activity Diagram 1 Outline Chapter 6 Topics 6.6 C++ Standard Library Header Files 6.14 Inline Functions 6.16 Default Arguments 6.17 Unary Scope Resolution Operator

More information

the gamedesigninitiative at cornell university Lecture 7 C++ Overview

the gamedesigninitiative at cornell university Lecture 7 C++ Overview Lecture 7 Lecture 7 So You Think You Know C++ Most of you are experienced Java programmers Both in 2110 and several upper-level courses If you saw C++, was likely in a systems course Java was based on

More information

QUIZ. Source:

QUIZ. Source: QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Ch. 4: Data Abstraction The only way to get massive increases in productivity is to leverage off other people s code. That

More information

TMS470 ARM ABI Migration

TMS470 ARM ABI Migration TMS470 ARM ABI Migration Version Primary Author(s) V0.1 Anbu Gopalrajan V0.2 Anbu Gopalrajan Revision History Description of Version Date Completed Initial Draft 10/29/2006 Added C auto initialization

More information

Lecture 10: building large projects, beginning C++, C++ and structs

Lecture 10: building large projects, beginning C++, C++ and structs CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 10:

More information

CE221 Programming in C++ Part 1 Introduction

CE221 Programming in C++ Part 1 Introduction CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

More information

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured Introduction p. xxix The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured Language p. 6 C Is a Programmer's Language

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Lecture Topics. Administrivia

Lecture Topics. Administrivia ECE498SL Lec. Notes L8PA Lecture Topics overloading pitfalls of overloading & conversions matching an overloaded call miscellany new & delete variable declarations extensibility: philosophy vs. reality

More information

Cpt S 122 Data Structures. Introduction to C++ Part II

Cpt S 122 Data Structures. Introduction to C++ Part II Cpt S 122 Data Structures Introduction to C++ Part II Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Objectives Defining class with a member function

More information

Fast Introduction to Object Oriented Programming and C++

Fast Introduction to Object Oriented Programming and C++ Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

Software Engineering /48

Software Engineering /48 Software Engineering 1 /48 Topics 1. The Compilation Process and You 2. Polymorphism and Composition 3. Small Functions 4. Comments 2 /48 The Compilation Process and You 3 / 48 1. Intro - How do you turn

More information

Supporting Class / C++ Lecture Notes

Supporting Class / C++ Lecture Notes Goal Supporting Class / C++ Lecture Notes You started with an understanding of how to write Java programs. This course is about explaining the path from Java to executing programs. We proceeded in a mostly

More information

QUIZ. What is wrong with this code that uses default arguments?

QUIZ. What is wrong with this code that uses default arguments? QUIZ What is wrong with this code that uses default arguments? Solution The value of the default argument should be placed in either declaration or definition, not both! QUIZ What is wrong with this code

More information

Have examined process Creating program Have developed program Written in C Source code

Have examined process Creating program Have developed program Written in C Source code 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

More information

Ch. 3: The C in C++ - Continued -

Ch. 3: The C in C++ - Continued - Ch. 3: The C in C++ - Continued - QUIZ What are the 3 ways a reference can be passed to a C++ function? QUIZ True or false: References behave like constant pointers with automatic dereferencing. QUIZ What

More information

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object CHAPTER 1 Introduction to Computers and Programming 1 1.1 Why Program? 1 1.2 Computer Systems: Hardware and Software 2 1.3 Programs and Programming Languages 8 1.4 What is a Program Made of? 14 1.5 Input,

More information

DDMD AND AUTOMATED CONVERSION FROM C++ TO D

DDMD AND AUTOMATED CONVERSION FROM C++ TO D 1 DDMD AND AUTOMATED CONVERSION FROM C++ TO D Daniel Murphy (aka yebblies ) ABOUT ME Using D since 2009 Compiler contributor since 2011 2 OVERVIEW Why convert the frontend to D What s so hard about it

More information

Starting to Program in C++ (Basics & I/O)

Starting to Program in C++ (Basics & I/O) Copyright by Bruce A. Draper. 2017, All Rights Reserved. Starting to Program in C++ (Basics & I/O) On Tuesday of this week, we started learning C++ by example. We gave you both the Complex class code and

More information

10CS36: Object Oriented Programming with C++

10CS36: Object Oriented Programming with C++ 10CS36: Object Oriented Programming with C++ Question Bank: UNIT 1: Introduction to C++ 1. What is Procedure-oriented Programming System? Dec 2005 2. What is Object-oriented Programming System? June 2006

More information

Interview Questions of C++

Interview Questions of C++ Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.

More information

Exercise. Game Programming in C++ Overview. Art vs. Science in Programming. Organising your code. Organising your code

Exercise. Game Programming in C++ Overview. Art vs. Science in Programming. Organising your code. Organising your code Exercise Game Programming in C++ Arjan Egges Lecture #5: The art of programming Write a function that calculates the frequency of a given character in a string, e.g. for string arjan and character a, the

More information

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26 COSC 2P95 Procedural Abstraction Week 3 Brock University Brock University (Week 3) Procedural Abstraction 1 / 26 Procedural Abstraction We ve already discussed how to arrange complex sets of actions (e.g.

More information

C++ Coding Standards and Practices. Tim Beaudet March 23rd 2015

C++ Coding Standards and Practices. Tim Beaudet March 23rd 2015 C++ Coding Standards and Practices Tim Beaudet (timbeaudet@yahoo.com) March 23rd 2015 Table of Contents Table of contents About these standards Project Source Control Build Automation Const Correctness

More information

QUIZ. Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed?

QUIZ. Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed? QUIZ Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed? Or Foo(x), depending on how we want the initialization

More information

C Review. MaxMSP Developers Workshop Summer 2009 CNMAT

C 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 information

Programming in Visual Basic with Microsoft Visual Studio 2010

Programming in Visual Basic with Microsoft Visual Studio 2010 Programming in Visual Basic with Microsoft Visual Studio 2010 Course 10550; 5 Days, Instructor-led Course Description This course teaches you Visual Basic language syntax, program structure, and implementation

More information

CSc 520 Principles of Programming Languages

CSc 520 Principles of Programming Languages CSc 520 Principles of Programming Languages 32: Procedures Inlining Christian Collberg collberg@cs.arizona.edu Department of Computer Science University of Arizona Copyright c 2005 Christian Collberg [1]

More information

Slide 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 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 information

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led CENTER OF KNOWLEDGE, PATH TO SUCCESS Website: PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO 2010 Course: 10550A; Duration: 5 Days; Instructor-led WHAT YOU WILL LEARN This course teaches you

More information

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Appendix. 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 information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Polymorphism. Zimmer CSCI 330

Polymorphism. Zimmer CSCI 330 Polymorphism Polymorphism - is the property of OOP that allows the run-time binding of a function's name to the code that implements the function. (Run-time binding to the starting address of the code.)

More information

C for C++ Programmers

C for C++ Programmers C for C++ Programmers CS230/330 - Operating Systems (Winter 2001). The good news is that C syntax is almost identical to that of C++. However, there are many things you're used to that aren't available

More information

September 10,

September 10, September 10, 2013 1 Bjarne Stroustrup, AT&T Bell Labs, early 80s cfront original C++ to C translator Difficult to debug Potentially inefficient Many native compilers exist today C++ is mostly upward compatible

More information

Preface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p.

Preface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p. Preface to the Second Edition p. iii Preface to the First Edition p. vi Brief Contents p. ix Introduction to C++ p. 1 A Review of Structures p. 1 The Need for Structures p. 1 Creating a New Data Type Using

More information

Figure 1 Common Sub Expression Optimization Example

Figure 1 Common Sub Expression Optimization Example General Code Optimization Techniques Wesley Myers wesley.y.myers@gmail.com Introduction General Code Optimization Techniques Normally, programmers do not always think of hand optimizing code. Most programmers

More information

Chapter 11 :: Functional Languages

Chapter 11 :: Functional Languages Chapter 11 :: Functional Languages Programming Language Pragmatics Michael L. Scott Copyright 2016 Elsevier 1 Chapter11_Functional_Languages_4e - Tue November 21, 2017 Historical Origins The imperative

More information

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE?

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE? 1. Describe History of C++? The C++ programming language has a history going back to 1979, when Bjarne Stroustrup was doing work for his Ph.D. thesis. One of the languages Stroustrup had the opportunity

More information

Better variadic functions in C

Better variadic functions in C Better variadic functions in C Ben Klemens XXX I really dislike how C s variadic functions are implemented. I think they create lots of problems and don t fulfil their potential. So this is my effort to

More information

C++ Important Questions with Answers

C++ Important Questions with Answers 1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children

More information

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

MODERN AND LUCID C++ ADVANCED

MODERN AND LUCID C++ ADVANCED Informatik MODERN AND LUCID C++ ADVANCED for Professional Programmers Prof. Peter Sommerlad Thomas Corbat Director of IFS Research Assistant Rapperswil, FS 2016 LIBRARY API/ABI DESIGN PIMPL IDIOM HOURGLASS

More information

C++ for System Developers with Design Pattern

C++ for System Developers with Design Pattern C++ for System Developers with Design Pattern Introduction: This course introduces the C++ language for use on real time and embedded applications. The first part of the course focuses on the language

More information

I m sure you have been annoyed at least once by having to type out types like this:

I m sure you have been annoyed at least once by having to type out types like this: Type Inference The first thing I m going to talk about is type inference. C++11 provides mechanisms which make the compiler deduce the types of expressions. These features allow you to make your code more

More information

ADTs & Classes. An introduction

ADTs & Classes. An introduction ADTs & Classes An introduction Quick review of OOP Object: combination of: data structures (describe object attributes) functions (describe object behaviors) Class: C++ mechanism used to represent an object

More information

Object-oriented features

Object-oriented features Chapter 1 Object-oriented features The compiler s job for a procedural language like C is relatively straightforward, because C and most other compiled procedural languages have been designed to approximate

More information

Kakadu and Java. David Taubman, UNSW June 3, 2003

Kakadu and Java. David Taubman, UNSW June 3, 2003 Kakadu and Java David Taubman, UNSW June 3, 2003 1 Brief Summary The Kakadu software framework is implemented in C++ using a fairly rigorous object oriented design strategy. All classes which are intended

More information

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 12, FALL 2012

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 12, FALL 2012 CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 12, FALL 2012 TOPICS TODAY Assembling & Linking Assembly Language Separate Compilation in C Scope and Lifetime LINKING IN ASSEMBLY

More information

CSE / ENGR 142 Programming I

CSE / ENGR 142 Programming I CSE / ENGR 142 Programming I Variables, Values, and Types Chapter 2 Overview Chapter 2: Read Sections 2.1-2.6, 2.8. Long chapter, short snippets on many topics Later chapters fill in detail Specifically:

More information

COM S 213 PRELIM EXAMINATION #2 April 26, 2001

COM S 213 PRELIM EXAMINATION #2 April 26, 2001 COM S 213 PRELIM EXAMINATION #2 April 26, 2001 Name: Student ID: Please answer all questions in the space(s) provided. Each question is worth 4 points. You may leave when you are finished with the exam.

More information

CSE 374 Programming Concepts & Tools. Hal Perkins Spring 2010

CSE 374 Programming Concepts & Tools. Hal Perkins Spring 2010 CSE 374 Programming Concepts & Tools Hal Perkins Spring 2010 Lecture 19 Introduction ti to C++ C++ C++ is an enormous language: g All of C Classes and objects (kind of like Java, some crucial differences)

More information

Programmazione. Prof. Marco Bertini

Programmazione. Prof. Marco Bertini Programmazione Prof. Marco Bertini marco.bertini@unifi.it http://www.micc.unifi.it/bertini/ Hello world : a review Some differences between C and C++ Let s review some differences between C and C++ looking

More information

CS11 Introduction to C++ Spring Lecture 8

CS11 Introduction to C++ Spring Lecture 8 CS11 Introduction to C++ Spring 2013-2014 Lecture 8 Local Variables string getusername() { string user; } cout user; return user;! What happens to user when function

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

Ch. 10: Name Control

Ch. 10: Name Control Ch. 10: Name Control Static elements from C The static keyword was overloaded in C before people knew what the term overload meant, and C++ has added yet another meaning. The underlying concept with all

More information

CS 240 Final Exam Review

CS 240 Final Exam Review CS 240 Final Exam Review Linux I/O redirection Pipelines Standard commands C++ Pointers How to declare How to use Pointer arithmetic new, delete Memory leaks C++ Parameter Passing modes value pointer reference

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

More information

Polymorphism. Contents. Assignment to Derived Class Object. Assignment to Base Class Object

Polymorphism. Contents. Assignment to Derived Class Object. Assignment to Base Class Object Polymorphism C++ Object Oriented Programming Pei-yih Ting NTOU CS 26-1 Contents Assignment to base / derived types of objects Assignment to base / derived types of pointers Heterogeneous container and

More information

A brief introduction to C++

A brief introduction to C++ A brief introduction to C++ Rupert Nash r.nash@epcc.ed.ac.uk 13 June 2018 1 References Bjarne Stroustrup, Programming: Principles and Practice Using C++ (2nd Ed.). Assumes very little but it s long Bjarne

More information

Topic 6: A Quick Intro To C. Reading. "goto Considered Harmful" History

Topic 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 information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

Programming in C and C++

Programming in C and C++ Programming in C and C++ 5. C++: Overloading, Namespaces, and Classes Dr. Neel Krishnaswami University of Cambridge (based on notes from and with thanks to Anil Madhavapeddy, Alan Mycroft, Alastair Beresford

More information

Auto - a necessary evil?

Auto - a necessary evil? Auto - a necessary evil? Roger Orr OR/2 Limited ACCU 2013 auto is new in C++11 It has been under discussion for a while, as we shall see Some compilers added support for it early in C++0x so it has had

More information

XII CS(EM) Minimum Question List N.KANNAN M.Sc., B.Ed COMPUTER SCIENCE IMPORTANT QUESTION (TWO MARKS) CHAPTER 1 TO 5 ( STAR OFFICE WRITER)

XII CS(EM) Minimum Question List N.KANNAN M.Sc., B.Ed COMPUTER SCIENCE IMPORTANT QUESTION (TWO MARKS) CHAPTER 1 TO 5 ( STAR OFFICE WRITER) COMPUTER SCIENCE IMPORTANT QUESTION (TWO MARKS) CHAPTER 1 TO 5 ( STAR OFFICE WRITER) 1. Selecting text with keyboard 2. Differ copying and moving 3. Text Editing 4. Creating a bulleted list 5. Creating

More information

Advanced C++ Topics. Alexander Warg, 2017

Advanced C++ Topics. Alexander Warg, 2017 www.kernkonzept.com Advanced C++ Topics Alexander Warg, 2017 M I C R O K E R N E L M A D E I N G E R M A N Y Overview WHAT IS BEHIND C++ Language Magics Object Life Time Object Memory Layout INTRODUCTION

More information

A Fast Review of C Essentials Part I

A 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 information

Lecture 14: more class, C++ streams

Lecture 14: more class, C++ streams CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 14:

More information

The following is an excerpt from Scott Meyers new book, Effective C++, Third Edition: 55 Specific Ways to Improve Your Programs and Designs.

The following is an excerpt from Scott Meyers new book, Effective C++, Third Edition: 55 Specific Ways to Improve Your Programs and Designs. The following is an excerpt from Scott Meyers new book, Effective C++, Third Edition: 55 Specific Ways to Improve Your Programs and Designs. Item 47: Use traits classes for information about types. The

More information

Chapter 15 - C++ As A "Better C"

Chapter 15 - C++ As A Better C Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference

More information

Introducing C++ David Chisnall. March 15, 2011

Introducing C++ David Chisnall. March 15, 2011 Introducing C++ David Chisnall March 15, 2011 Why Learn C++? Lots of people used it to write huge, unmaintainable code......which someone then gets paid a lot to maintain. C With Classes Predecessor of

More information

Stream Computing using Brook+

Stream Computing using Brook+ Stream Computing using Brook+ School of Electrical Engineering and Computer Science University of Central Florida Slides courtesy of P. Bhaniramka Outline Overview of Brook+ Brook+ Software Architecture

More information

Modules: ADL & Internal Linkage

Modules: ADL & Internal Linkage Document Number: p1347r1 Date: 2019-01-17 To: SC22/WG21 EWG Reply to: Davis Herring, Nathan Sidwell herring@lanl.gov, nathan@acm.org Re: p1103r1 Merging Modules Modules: ADL & Internal Linkage Nathan Sidwell,

More information

printf( Please enter another number: ); scanf( %d, &num2);

printf( 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 information

STRUCTURING OF PROGRAM

STRUCTURING OF PROGRAM Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the

More information

CSE 11 Style Guidelines

CSE 11 Style Guidelines CSE 11 Style Guidelines These style guidelines are based off of Google s Java Style Guide and Oracle s Javadoc Guide. Overview: Your style will be graded on the following items: File Headers Class Headers

More information

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d) CMSC 330: Organization of Programming Languages Tail Calls A tail call is a function call that is the last thing a function does before it returns let add x y = x + y let f z = add z z (* tail call *)

More information

TPF Users Group Spring 2005

TPF Users Group Spring 2005 TPF Users Group Spring 2005 Get Ready For Standard C++! Name : Edwin W. van de Grift Venue : Applications Development Subcommittee AIM Enterprise Platform Software IBM z/transaction Processing Facility

More information

Control 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++ 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 information

Basic Programming Language Syntax

Basic Programming Language Syntax Java Created in 1990 by Sun Microsystems. Free compiler from Sun, commercial from many vendors. We use free (Sun) Java on UNIX. Compiling and Interpreting...are processes of translating a high-level programming

More information

CS11 Introduction to C++ Fall Lecture 6

CS11 Introduction to C++ Fall Lecture 6 CS11 Introduction to C++ Fall 2006-2007 Lecture 6 Today s Topics C++ exceptions Introduction to templates How To Report Errors? C style of error reporting: return values For C Standard Library/UNIX functions,

More information

Classes. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT).

Classes. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT). UNITII Classes Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT). It s a User Defined Data-type. The Data declared in a Class are called Data- Members

More information

G52CPP C++ Programming Lecture 9

G52CPP C++ Programming Lecture 9 G52CPP C++ Programming Lecture 9 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last lecture const Constants, including pointers The C pre-processor And macros Compiling and linking And

More information

Overview. Constructors and destructors Virtual functions Single inheritance Multiple inheritance RTTI Templates Exceptions Operator Overloading

Overview. Constructors and destructors Virtual functions Single inheritance Multiple inheritance RTTI Templates Exceptions Operator Overloading How C++ Works 1 Overview Constructors and destructors Virtual functions Single inheritance Multiple inheritance RTTI Templates Exceptions Operator Overloading Motivation There are lot of myths about C++

More information

Problem Solving with C++

Problem Solving with C++ GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter

More information

Author: Steve Gorman Title: Programming with the Intel architecture in the flat memory model

Author: Steve Gorman Title: Programming with the Intel architecture in the flat memory model Author: Steve Gorman Title: Programming with the Intel architecture in the flat memory model Abstract: As the Intel architecture moves off the desktop into a variety of other computing applications, developers

More information

CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer

CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer Assigned: Thursday, September 16, 2004 Due: Tuesday, September 28, 2004, at 11:59pm September 16, 2004 1 Introduction Overview In this

More information

Accept all the default choices in the Wizard's pages.

Accept all the default choices in the Wizard's pages. XLL+ Overview XLL+ is a C++ add-in which assists users in creating Excel add-in components. Two key components assist developers in creating Excel add-ins more quickly and requiring less debugging: AppWizard

More information

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am CMSC 202 Section 010x Spring 2007 Computer Science II Final Exam Name: Username: Score Max Section: (check one) 0101 - Justin Martineau, Tuesday 11:30am 0102 - Sandeep Balijepalli, Thursday 11:30am 0103

More information

About this exam review

About this exam review Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review

More information

Modules: Contexts of Template Instantiations and Name Lookup Gabriel Dos Reis Microsoft

Modules: Contexts of Template Instantiations and Name Lookup Gabriel Dos Reis Microsoft Modules: Contexts of Template Instantiations and Name Lookup Gabriel Dos Reis Microsoft Background One of the design principles behind modules is to ensure that the working programmer does not need to

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Borland 105, 278, 361, 1135 Bounded array Branch instruction 7 break statement 170 BTree 873 Building a project 117 Built in data types 126

Borland 105, 278, 361, 1135 Bounded array Branch instruction 7 break statement 170 BTree 873 Building a project 117 Built in data types 126 INDEX = (assignment operator) 130, 816 = 0 (as function definition) 827 == (equality test operator) 146! (logical NOT operator) 159!= (inequality test operator) 146 #define 140, 158 #include 100, 112,

More information

Operator overloading

Operator 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 information

1/29/2011 AUTO POINTER (AUTO_PTR) INTERMEDIATE SOFTWARE DESIGN SPRING delete ptr might not happen memory leak!

1/29/2011 AUTO POINTER (AUTO_PTR) INTERMEDIATE SOFTWARE DESIGN SPRING delete ptr might not happen memory leak! //Example showing a bad situation with naked pointers CS 251 INTERMEDIATE SOFTWARE DESIGN SPRING 2011 C ++ Basics Review part 2 Auto pointer, templates, STL algorithms void MyFunction() MyClass* ptr( new

More information