1.1 The hand written header file

Size: px
Start display at page:

Download "1.1 The hand written header file"

Transcription

1 Page 1 of 8 Incorporating hand code data with generated code from 1 Overview models This paper illustrates how to integrate hand-code with the code generated from models. In particular, it will illustrate how to take three pieces of data that are defined in hand-written files and generate code from a model that will compile with the hand-written files without any handmodification of code. For this example, the hand-written files consist of a header file and a source file that provide three pieces of data: two signals and a parameter. 1.1 The hand written header file #ifndef _HAND_WRITEN_FILE_H_ # define _HAND_WRITEN_FILE_ extern double hand_code_signal_variable_a; extern double * hand_code_signal_variable_b_ptr; extern double hand_code_parameter_c; #else /* This file has already been included. */ #endif /* _HAND_WRITEN_FILE_H_ */ The example header file, hand_written_file.h, simply provides extern declarations of the data. In this case, hand_code_signal_variable_a will be accessed directly, but hand_code_signal_variable_b_ptr is a pointer and must be dereferenced when it is used (e.g. (*hand_code_signal_variable_b_ptr)). Text 1: hand_written_file.h 1.2 The hand written source file The example source file, hand_written_file.c, provides the actual definitions of the data. This file also clarifies why hand_code_signal_variable_b_ptr has to be a pointer instead of a normal variable; In this case, it points to a hardware address instead of a normal variable. Also, this file also defines the value of hand_code_parameter_c, and the initial value of hand_code_signal_variable_a which are relevant because it is necessary to ensure that simulation uses the same values that will be compiled into the generated code. #ifndef _HAND_WRITEN_FILE_C_ # define _HAND_WRITEN_FILE_C_ # include "hand_written_file.h" # define HARDWARE_ADDRESS ((double *)12345) double hand_code_signal_variable_a; double * hand_code_signal_variable_b_ptr = HARDWARE_ADDRESS; double hand_code_parameter_c = 42; #else /* This file has already been included. */ #endif /* _HAND_WRITEN_FILE_C_ */ Text 2: hand_written_file.c

2 Page 2 of The model The model for this example, will be named model_using_external_variables.mdl, and will be a simple use of a Gain block applied to an incoming signal, as illustrated below: Illustration 1: Initial model_using_external_variables.mdl This model will incorporate the three pieces of data from the hand-written files in the following manner: hand_code_signal_variable_a will be the incoming signal hand_code_signal_variable_b_ptr will be the outgoing signal hand_code_parameter_c will be the gain value applied to the incoming signal to produce the outgoing signal. It is worth noting that, from a C programming perspective, these pieces of data are all declared and defined in roughly the same fashion, and the distinctions between input signals, output signals, and parameters is defined by how the data will be used in the model. 2 Steps In order to use this data in the generated code, it will be necessary to ensure that the generated code to do two things: Use the data, as named in the hand-written files, in the generated code: This will be done by creating data objects and applying them to elements of the model, as well as modifying the model's Configuration Parameters. Include the hand-written files into the model's build process: This will be done by modifying the model's Configuration Parameters. 2.1 Using the data Data objects provide a mechanism for controlling the code-generation details of signals and parameters. In this case, it will be necessary to create data objects for hand_code_signal_variable_a, hand_code_signal_variable_b_ptr and hand_code_parameter_c. These data objects can be created using the following m-code:

3 Page 3 of 8 function create_hand_written_file_data_objects() hand_code_signal_variable_a = mpt.signal; hand_code_signal_variable_a.rtwinfo.storageclass = 'Custom'; hand_code_signal_variable_a.rtwinfo.customstorageclass = 'ImportFromFile'; hand_code_signal_variable_a.rtwinfo.customattributes.dataaccess = 'Direct'; hand_code_signal_variable_a.rtwinfo.customattributes.headerfile = 'hand_written_file.h'; hand_code_signal_variable_a.datatype = 'double'; hand_code_signal_variable_a.initialvalue = '42.0'; hand_code_signal_variable_b_ptr = mpt.signal; hand_code_signal_variable_b_ptr.rtwinfo.storageclass = 'Custom'; hand_code_signal_variable_b_ptr.rtwinfo.customstorageclass = 'ImportFromFile'; hand_code_signal_variable_b_ptr.rtwinfo.customattributes.dataaccess = 'Pointer'; hand_code_signal_variable_b_ptr.rtwinfo.customattributes.headerfile = 'hand_written_file.h'; hand_code_signal_variable_b_ptr.datatype = 'double'; hand_code_parameter_c = mpt.parameter; hand_code_parameter_c.value = double(2112.0); hand_code_parameter_c.rtwinfo.storageclass = 'Custom'; hand_code_parameter_c.rtwinfo.customstorageclass = 'ImportFromFile'; hand_code_parameter_c.rtwinfo.customattributes.dataaccess = 'Direct'; hand_code_parameter_c.rtwinfo.customattributes.headerfile = 'hand_written_file.h'; assignin('base', 'hand_code_signal_variable_a', hand_code_signal_variable_a); assignin('base', 'hand_code_signal_variable_b_ptr', hand_code_signal_variable_b_ptr); assignin('base', 'hand_code_parameter_c', hand_code_parameter_c); end Text 3: create_hand_written_file_data_objects.m After running this code, the data objects now exist in the base workspace, but the model does not yet use them. The next step is to associate these data objects with elements of the model Associating model signals with signal data objects To associate a model signal with a signal data object in the base workspace, 1. Right-click on the signal line to be associated with the data object, and select Signal Properties. 2. Enter the name of the data object into the Signal name text field. 3. Check the Signal name must resolve to Simulink signal object box. 4. Click OK. Illustration 2: Signal Properties window

4 Page 4 of Associating block dialog parameters with parameter data objects To associate a parameter data object in the base workspace with a block: 1. Use the parameter name in a block dialog 2. Inline parameters, by opening Simulation- >Configuration Parameters, then selecting Optimization from the tree on the left, and then checking the box for Inline parameters. Illustration 3: Gain block parameters dialog Illustration 4: Configuration Parameters, Optimization pane After naming the signals and adding the parameter to the Gain block, the final model should look like the following:

5 Page 5 of 8 Illustration 5: Completed model_using_external_variables.mdl With the data objects properly associated with the model, the generated code will now contain some of the key elements that are required to make use of the generated code, including: Preprocessor inclusion directives /* Includes for objects with custom storage classes. */ #include "hand_written_file.h" Text 4: From model_using_external_variables_private.h Use of the correct variable names #include "model_using_external_variables.h" #include "model_using_external_variables_private.h" /* Model step function */ void model_using_external_variables_step(void) { /* Gain: '<Root>/Gain' incorporates: * Inport: '<Root>/In1' */ (*hand_code_signal_variable_b_ptr) = hand_code_parameter_c * hand_code_signal_variable_a; } Text 5: From model_using_external_variables.c However, even though the resulting code will be correct, Real-Time Workshop is not yet able to compile or link it because it is not yet able to access the hand-written header and source files during the build process.

6 Page 6 of Including the hand written files into the build process Including the path to the hand written header file in the generated makefile The code-generation associated with the data objects causes the correct # include statements to be produced, but the actual header file is not in any of the directories that the compiler will access. It is therefore necessary to add the directory containing the header file to the build command. To do this: 1. Open Simulation->Configuration Parameters. 2. Select Real-Time Workshop->Custom Code from the tree on the left. 3. Select Include directories the Include list of additional (lower) section. 4. Enter the path to the header files, not including the actual name of the header file, which is actually specified by the # include statement. The path may either be absolute, or relative to the model file. Illustration 6: Configuration parameters, include directories pane This results in the following information being added to the automatically-generated makefile:

7 Page 7 of 8 # Additional includes ADD_INCLUDES = \ -I/path/to/model/file/model/model_using_external_variables_ert_rtw \ -I/path/to/model/file/model \ -I/path/to/model/file/model/../hand_code \ -I$(MATLAB_ROOT)/rtw/c/libsrc \ Text 6: From model_using_external_variables.mk Including the hand written source file in the generated makefile's build list Having completed the above steps, the model will successfully compile, however the linking process will fail because there is no object file that actually defines hand_code_signal_variable_a, hand_code_signal_variable_b_ptr or hand_code_parameter_c, so the references in the generated code (and header file) remain unresolved. The solution is to add hand_written_file.c to the makefile for compilation. To do this: 1. Open Simulation->Configuration Parameters. 2. Select Real-Time Workshop->Custom Code from the tree on the left 3. In the Include list of additional (lower pane) section, select Source files. 4. In the Source files (lower pane) section enter the path and file name (either an absolute path, or relative to this model file). Illustration 7: Configuration Parameters, Source files pane

8 Page 8 of 8 This will produce the following addition to the generated makefile: MODEL MODULES = model_using_external_variables = hand_written_file.c %.o : /path/to/model/file/model/../hand_code/%.c $(CC) -c $(CFLAGS) $(GCC_WALL_FLAG_MAX) "$<" %.o : /path/to/model/file/model/../hand_code/%.cpp $(CPP) -c $(CPPFLAGS) $(GCC_WALL_FLAG_MAX) "$<" Text 7: From model_using_external_variables.mk

Separate Compilation of Multi-File Programs

Separate Compilation of Multi-File Programs 1 About Compiling What most people mean by the phrase "compiling a program" is actually two separate steps in the creation of that program. The rst step is proper compilation. Compilation is the translation

More information

TDDE18 & 726G77. Functions

TDDE18 & 726G77. Functions TDDE18 & 726G77 Functions Labs update No more one time password. We will note who have demonstrated during the lab and register this in webreg. Use the terminal to send in your lab! Dont use Visual studio

More information

Object Oriented Design

Object Oriented Design Object Oriented Design Chapter 9 Initializing a non-static data member in the class definition is a syntax error 1 9.2 Time Class Case Study In Fig. 9.1, the class definition is enclosed in the following

More information

CMPSC 311- Introduction to Systems Programming Module: Build Processing

CMPSC 311- Introduction to Systems Programming Module: Build Processing CMPSC 311- Introduction to Systems Programming Module: Build Processing Professor Patrick McDaniel Fall 2016 UNIX Pipes Pipes are ways of redirecting the output of one command to the input of another Make

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

INTERMEDIATE SOFTWARE DESIGN SPRING 2011 ACCESS SPECIFIER: SOURCE FILE

INTERMEDIATE SOFTWARE DESIGN SPRING 2011 ACCESS SPECIFIER: SOURCE FILE HEADER FILE A header (.h,.hpp,...) file contains Class definitions ( class X {... }; ) Inline function definitions ( inline int get_x() {... } ) Function declarations ( void help(); ) Object declarations

More information

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

Program Translation. text. text. binary. binary. C program (p1.c) Compiler (gcc -S) Asm code (p1.s) Assembler (gcc or as) Object code (p1.

Program Translation. text. text. binary. binary. C program (p1.c) Compiler (gcc -S) Asm code (p1.s) Assembler (gcc or as) Object code (p1. Program Translation Compilation & Linking 1 text C program (p1.c) Compiler (gcc -S) text Asm code (p1.s) binary binary Assembler (gcc or as) Object code (p1.o) Linker (gccor ld) Executable program (p)

More information

Generating ASAP2 Files

Generating ASAP2 Files 1 Generating ASAP2 Files Overview...................... 1-2 Targets Supporting ASAP2.............. 1-3 Defining ASAP2 Information.............. 1-3 Generating an ASAP2 File............... 1-6 Customizing

More information

Makefiles are a simple way to organize code compilation. Using a makefile it is possible to compile several source files to produce an executable;

Makefiles are a simple way to organize code compilation. Using a makefile it is possible to compile several source files to produce an executable; Makefile Makefiles are a simple way to organize code compilation. Using a makefile it is possible to compile several source files to produce an executable; Source (.cc) and header (.h) files can be placed

More information

INHERITANCE: CONSTRUCTORS,

INHERITANCE: CONSTRUCTORS, INHERITANCE: CONSTRUCTORS, DESTRUCTORS, HEADER FILES Pages 720 to 731 Anna Rakitianskaia, University of Pretoria CONSTRUCTORS Constructors are used to create objects Object creation = initialising member

More information

2 Compiling a C program

2 Compiling a C program 2 Compiling a C program This chapter describes how to compile C programs using gcc. Programs can be compiled from a single source file or from multiple source files, and may use system libraries and header

More information

The Compilation Process

The Compilation Process The Compilation Process Olaf Lenz http://wwwicpuni-stuttgartde Institut für Computerphysik Universität Stuttgart March 17-21, 2014 Separate Compilation http://wwwicpuni-stuttgartde So far, all programs

More information

Lecture Notes on Generic Data Structures

Lecture Notes on Generic Data Structures Lecture Notes on Generic Data Structures 15-122: Principles of Imperative Computation Frank Pfenning Lecture 22 November 15, 2012 1 Introduction Using void* to represent pointers to values of arbitrary

More information

Lab 2: ADT Design & Implementation

Lab 2: ADT Design & Implementation Lab 2: ADT Design & Implementation By Dr. Yingwu Zhu, Seattle University 1. Goals In this lab, you are required to use a dynamic array to design and implement an ADT SortedList that maintains a sorted

More information

CS2141 Software Development using C/C++ Compiling a C++ Program

CS2141 Software Development using C/C++ Compiling a C++ Program CS2141 Software Development using C/C++ Compiling a C++ Program g++ g++ is the GNU C++ compiler. A program in a file called hello.cpp: #include using namespace std; int main( ) { cout

More information

Project structure - working with multiple les

Project structure - working with multiple les Project structure - working with multiple les Declaration and denition Recall the dierence between declaration... double max( double a, double b ); and denition... double max( double a, double b ) { if

More information

Object-Oriented Programming

Object-Oriented Programming iuliana@cs.ubbcluj.ro Babes-Bolyai University 2018 1 / 37 Overview 1 2 3 4 5 2 / 37 Questions we will answer today What is the difference between the stack and the heap? How can we allocate and free memory

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

Overview of today s lecture. Quick recap of previous C lectures. Introduction to C programming, lecture 2. Abstract data type - Stack example

Overview of today s lecture. Quick recap of previous C lectures. Introduction to C programming, lecture 2. Abstract data type - Stack example Overview of today s lecture Introduction to C programming, lecture 2 -Dynamic data structures in C Quick recap of previous C lectures Abstract data type - Stack example Make Refresher: pointers Pointers

More information

Program Translation. text. text. binary. binary. C program (p1.c) Compiler (gcc -S) Asm code (p1.s) Assembler (gcc or as) Object code (p1.

Program Translation. text. text. binary. binary. C program (p1.c) Compiler (gcc -S) Asm code (p1.s) Assembler (gcc or as) Object code (p1. Program Translation Compilation & Linking 1 text C program (p1.c) Compiler (gcc -S) text Asm code (p1.s) binary binary Assembler (gcc or as) Object code (p1.o) Linker (gcc or ld) Executable program (p1)

More information

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above

More information

OBJECT ORIENTED PROGRAMMING USING C++

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 information

CMPSC 311- Introduction to Systems Programming Module: Build Processing

CMPSC 311- Introduction to Systems Programming Module: Build Processing CMPSC 311- Introduction to Systems Programming Module: Build Processing Professor Patrick McDaniel Fall 2014 UNIX Pipes Pipes are ways of redirecting the output of one command to the input of another Make

More information

Advanced Programming & C++ Language

Advanced Programming & C++ Language Advanced Programming & C++ Language ~1~ Introduction. Compilation Process Ariel University 2018 Dr. Miri (Kopel) Ben-Nissan 2 Administration Stuff Final Exam: 70% Exercises: 30% Both lectures and exercises

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

Professor Terje Haukaas University of British Columbia, Vancouver C++ Programming

Professor Terje Haukaas University of British Columbia, Vancouver  C++ Programming C++ Programming C++ code is essentially a collection of statements terminated by a semicolon, such as (spaces not needed): a = b + c; Most C++ code is organized into header files and cpp files, i.e., C++

More information

CS520 Setting Up the Programming Environment for Windows Suresh Kalathur. For Windows users, download the Java8 SDK as shown below.

CS520 Setting Up the Programming Environment for Windows Suresh Kalathur. For Windows users, download the Java8 SDK as shown below. CS520 Setting Up the Programming Environment for Windows Suresh Kalathur 1. Java8 SDK Java8 SDK (Windows Users) For Windows users, download the Java8 SDK as shown below. The Java Development Kit (JDK)

More information

Due Date: See Blackboard

Due Date: See Blackboard Source File: ~/2315/45/lab45.(C CPP cpp c++ cc cxx cp) Input: under control of main function Output: under control of main function Value: 4 Integer data is usually represented in a single word on a computer.

More information

Portable C Code

Portable C Code Chapter 6: Implementing Fuzzy Runtime Systems 6.1.4. Portable C Code The source codes generated by the fuzzytech C code generator are portable. Thus, fuzzy runtime systems can be implemented on any target

More information

C PROGRAMMING LANGUAGE. POINTERS, ARRAYS, OPERATORS AND LOOP. CAAM 519, CHAPTER5

C PROGRAMMING LANGUAGE. POINTERS, ARRAYS, OPERATORS AND LOOP. CAAM 519, CHAPTER5 C PROGRAMMING LANGUAGE. POINTERS, ARRAYS, OPERATORS AND LOOP. CAAM 519, CHAPTER5 1. Pointers As Kernighan and Ritchie state, a pointer is a variable that contains the address of a variable. They have been

More information

Entity vs. Value, Modules, Hidden Implementation, Interface Specification

Entity vs. Value, Modules, Hidden Implementation, Interface Specification Entity vs. Value, Modules, Hidden Implementation, Interface Specification CS 247 University of Waterloo cs247@uwaterloo.ca May 19, 2017 CS 247 (UW) Tutorial 3 May 19, 2017 1 / 24 Overview 1 Move Constructors,

More information

Module 3: Working with C/C++

Module 3: Working with C/C++ Module 3: Working with C/C++ Objective Learn basic Eclipse concepts: Perspectives, Views, Learn how to use Eclipse to manage a remote project Learn how to use Eclipse to develop C programs Learn how to

More information

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2 Compiling a C program CS Basics 15) Compiling a C prog. Emmanuel Benoist Fall Term 2016-17 Example of a small program Makefile Define Variables Compilation options Conclusion Berner Fachhochschule Haute

More information

Using Virtual EEPROM and Flash API for Renesas MCUs RX600 Series

Using Virtual EEPROM and Flash API for Renesas MCUs RX600 Series Using Virtual EEPROM and Flash API for Renesas MCUs RX600 Series Description: This lab will take the user through using the Virtual EEPROM (VEE) project for RX. The user will learn to use the Virtual EEPROM

More information

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

CS Basics 15) Compiling a C prog.

CS Basics 15) Compiling a C prog. CS Basics 15) Compiling a C prog. Emmanuel Benoist Fall Term 2016-17 Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1 Compiling a C program Example of a small

More information

C: Program Structure. Department of Computer Science College of Engineering Boise State University. September 11, /13

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

qmake for MeVisLab - Documentation

qmake for MeVisLab - Documentation qmake for MeVisLab - Documentation 1 qmake for MeVisLab - Documentation qmake for MeVisLab - Documentation 2 Table of Contents 1. qmake and MeVisLab... 4 1.1. Introduction to qmake... 4 1.2. Syntax in.pro

More information

Getting Started with QAC / QAC++

Getting Started with QAC / QAC++ Getting Started with QAC / QAC++ Table of Contents 1 Introduction... 2 2 Product Versions... 2 3 License Server... 2 4 Creating a Project... 3 4.1 Visual Studio... 3 4.2 Makefile Environment... 3 4.3 Eclipse/Wind

More information

make and makefile CS 211

make and makefile CS 211 make and makefile CS 211 Steps of a C Program Compilation Step 1 Run the Preprocessor Deals with #include, #define, #ifndef, Step 2 Compile C code into Machine Code Step 2a Lexical Analysis Step 2b Parsing

More information

CS 580 FINAL EXAM. Fall April 29, 2014

CS 580 FINAL EXAM. Fall April 29, 2014 CS 580 FINAL EXAM Fall 201 April 29, 2014 You are to build a range tree for your final exam. A range tree is a tree where each node contains a minimum and a maximum value as well as a linked list to store

More information

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli Identify and overcome the difficulties encountered by students when learning how to program List and explain the software development roles played by students List and explain the phases of the tight spiral

More information

C++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace

C++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace C++ Style Guide 1.0 General The purpose of the style guide is not to restrict your programming, but rather to establish a consistent format for your programs. This will help you debug and maintain your

More information

Introduction. Purpose. Objectives. Content. Learning Time

Introduction. Purpose. Objectives. Content. Learning Time Introduction Purpose This course gives an overview of assembler settings of the High-performance Embedded Workshop (HEW), used for developing software for embedded systems built with microcontrollers (MCUs)

More information

CSI33 Data Structures

CSI33 Data Structures Outline Department of Mathematics and Computer Science Bronx Community College October 25, 2017 Outline Outline 1 Chapter 8: A C++ Introduction For Python Programmers Function Details Assert Statements

More information

Topic 6: A Quick Intro To C

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

Conditional Compilation

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

Using Project Files. The Problem

Using Project Files. The Problem Using Project Files The Problem Usually, when we write a small program, we would put all the function prototypes, the function definitions and the main program all in one file. For example: example1.cpp

More information

Errors During Compilation and Execution Background Information

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

Appendix A. The Preprocessor

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

Chapter 9 Classes : A Deeper Look, Part 1

Chapter 9 Classes : A Deeper Look, Part 1 Chapter 9 Classes : A Deeper Look, Part 1 C++, How to Program Deitel & Deitel Fall 2016 CISC1600 Yanjun Li 1 Time Class Case Study Time Class Definition: private data members: int hour; int minute; int

More information

simple software flow analysis using GNU cflow

simple software flow analysis using GNU cflow CHAOS GOLUBITSKY simple software flow analysis using GNU cflow Chaos Golubitsky is a software security analyst. She has a BA from Swarthmore College, a background in UNIX system administration, and an

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

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

University of Toronto

University of Toronto University of Toronto Faculty of Applied Science and Engineering Midterm October, 2009 ECE244 --- Programming Fundamentals Examiners: Courtney Gibson, Wael Aboelsaadat, and Michael Stumm Instructions:

More information

Page 1. Agenda. Programming Languages. C Compilation Process

Page 1. Agenda. Programming Languages. C Compilation Process EE 472 Embedded Systems Dr. Shwetak Patel Assistant Professor Computer Science & Engineering Electrical Engineering Agenda Announcements C programming intro + pointers Shwetak N. Patel - EE 472 2 Programming

More information

EL6483: Brief Overview of C Programming Language

EL6483: 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 information

CSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready.

CSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready. Name: CSE 303, Winter 2007, Final Examination 15 March 2007 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for two 8.5x11in pieces of paper (both

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

Lectures 5-6: Introduction to C

Lectures 5-6: Introduction to C Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most

More information

Introducing C++ to Java Programmers

Introducing C++ to Java Programmers Introducing C++ to Java Programmers by Kip Irvine updated 2/27/2003 1 Philosophy of C++ Bjarne Stroustrup invented C++ in the early 1980's at Bell Laboratories First called "C with classes" Design Goals:

More information

Using Eclipse. Computational Thinking and Engineering for pre-college! Using Eclipse. Must READ:

Using Eclipse. Computational Thinking and Engineering for pre-college! Using Eclipse. Must READ: Must READ: Eclipse has far smaller footprint. However, it is more complicated to set up. Just like most OpenSource software, you might have to manually modify some system configuration. If you are not

More information

TREX Set-Up Guide: Creating a TREX Executable File for Windows

TREX Set-Up Guide: Creating a TREX Executable File for Windows TREX Set-Up Guide: Creating a TREX Executable File for Windows Prepared By: HDR 1 International Boulevard, 10 th Floor, Suite 1000 Mahwah, NJ 07495 May 13, 2013 Creating a TREX Executable File for Windows

More information

Adding a New Class. In this Chapter: T Defining a New Class. T Adding a New Class Attribute to the app Class. T app Class: Attribute Restrictions

Adding a New Class. In this Chapter: T Defining a New Class. T Adding a New Class Attribute to the app Class. T app Class: Attribute Restrictions Adding a New Class In this Chapter: T Defining a New Class T Adding a New Class Attribute to the app Class T app Class: Attribute Restrictions The Official AppGameKit Tier 2 Starter s Guide: Adding a New

More information

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

GNU make... Martin Ohlerich, Parallel Programming of High Performance Systems

GNU make... Martin Ohlerich, Parallel Programming of High Performance Systems ... Martin Ohlerich, Martin.Ohlerich@lrz.de Parallel Programming of High Performance Systems Outline 1 2 3 Leibniz Rechenzentrum 2 / 42 Outline 1 2 3 Leibniz Rechenzentrum 3 / 42 Common Situation Larger

More information

Simple vs Structured Data

Simple vs Structured Data Simple vs Structured Data Scalar Data Types - int, float An atomic data item One memory location for a symbolic name Cannot be decomposed Structured Data Types - arrays, structs, union, class A collection

More information

Faculty of Science Final Examination. Computer Science B Introduction to Software Systems

Faculty of Science Final Examination. Computer Science B Introduction to Software Systems Student Name: Student Number: Faculty of Science Final Examination Computer Science 308-206B Introduction to Software Systems Examiner: Hans Vangheluwe Monday, April 30 th, 2001 Associate Examiner: Charles

More information

CSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready.

CSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready. Name: CSE 303, Winter 2007, Final Examination 15 March 2007 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for two 8.5x11in pieces of paper (both

More information

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

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

Summer May 11, 2010

Summer May 11, 2010 Summer 2010 Department of Computer Science and Engineering York University Toronto May 11, 2010 1 / 40 What we did last time Overview of C to the language Program structure Types in C Operators in C IO

More information

The Automated Analysis of Header Files for Support of the Standardization Process

The Automated Analysis of Header Files for Support of the Standardization Process The Automated Analysis of Header Files for Support of the Standardization Process Eugene Novikov ISP RAS joker@ispras.ru Denis Silakov ISP RAS silakov@ispras.ru Abstract This paper considers the method

More information

Modifiers. int foo(int x) { static int y=0; /* value of y is saved */ y = x + y + 7; /* across invocations of foo */ return y; }

Modifiers. int foo(int x) { static int y=0; /* value of y is saved */ y = x + y + 7; /* across invocations of foo */ return y; } Modifiers unsigned. For example unsigned int would have a range of [0..2 32 1] on a 32-bit int machine. const Constant or read-only. Same as final in Java. static Similar to static in Java but not the

More information

The Structure of a C++ Program

The Structure of a C++ Program Steven Zeil May 25, 2013 Contents 1 Separate Compilation 3 1.1 Separate Compilation.......... 4 2 Pre-processing 7 2.1 #include.................. 9 2.2 Other Pre-processing Commands... 14 3 Declarations

More information

Chapter 7: Preprocessing Directives

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

Lecture Notes on Generic Data Structures

Lecture Notes on Generic Data Structures Lecture Notes on Generic Data Structures 15-122: Principles of Imperative Computation Frank Pfenning, Penny Anderson Lecture 21 November 7, 2013 1 Introduction Using void* to represent pointers to values

More information

Visual C++ Tutorial. For Introduction to Programming with C++ By Y. Daniel Liang

Visual C++ Tutorial. For Introduction to Programming with C++ By Y. Daniel Liang 1 Introduction Visual C++ Tutorial For Introduction to Programming with C++ By Y. Daniel Liang Visual C++ is a component of Microsoft Visual Studio 2012 for developing C++ programs. A free version named

More information

CptS 360 (System Programming) Unit 3: Development Tools

CptS 360 (System Programming) Unit 3: Development Tools CptS 360 (System Programming) Unit 3: Development Tools Bob Lewis School of Engineering and Applied Sciences Washington State University Spring, 2018 Motivation Using UNIX-style development tools lets

More information

Chapter 13: Introduction to Classes Procedural and Object-Oriented Programming

Chapter 13: Introduction to Classes Procedural and Object-Oriented Programming Chapter 13: Introduction to Classes 1 13.1 Procedural and Object-Oriented Programming 2 Procedural and Object-Oriented Programming Procedural programming focuses on the process/actions that occur in a

More information

pure::variants Connector for Source Code Management Manual

pure::variants Connector for Source Code Management Manual pure::variants Connector for Source Code Management Manual pure-systems GmbH Version 4.0.12.685 for pure::variants 4.0 Copyright 2003-2018 pure-systems GmbH 2018 Table of Contents 1. Introduction... 1

More information

COMsW Introduction to Computer Programming in C

COMsW Introduction to Computer Programming in C OMsW 1003-1 Introduction to omputer Programming in Lecture 9 Spring 2011 Instructor: Michele Merler http://www1.cs.columbia.edu/~mmerler/comsw1003-1.html 1 Are omputers Smarter than Humans? Link http://latimesblogs.latimes.com/technology/2011/02/ibms-watson-on-jeopardy-computer-takes-big-leadover-humans-in-round-2.html

More information

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

BASICS OF THE RENESAS SYNERGY TM

BASICS OF THE RENESAS SYNERGY TM BASICS OF THE RENESAS SYNERGY TM PLATFORM Richard Oed 2018.11 02 CHAPTER 9 INCLUDING A REAL-TIME OPERATING SYSTEM CONTENTS 9 INCLUDING A REAL-TIME OPERATING SYSTEM 03 9.1 Threads, Semaphores and Queues

More information

#include <stdio.h> int main() { printf ("hello class\n"); return 0; }

#include <stdio.h> int main() { printf (hello class\n); return 0; } C #include int main() printf ("hello class\n"); return 0; Working environment Linux, gcc We ll work with c9.io website, which works with ubuntu I recommend to install ubuntu too Also in tirgul

More information

Getting Started with Eclipse/Java

Getting Started with Eclipse/Java Getting Started with Eclipse/Java Overview The Java programming language is based on the Java Virtual Machine. This is a piece of software that Java source code is run through to produce executables. The

More information

Tutorial 1: Introduction to C Computer Architecture and Systems Programming ( )

Tutorial 1: Introduction to C Computer Architecture and Systems Programming ( ) Systems Group Department of Computer Science ETH Zürich Tutorial 1: Introduction to C Computer Architecture and Systems Programming (252-0061-00) Herbstsemester 2012 Goal Quick introduction to C Enough

More information

TypeChef: Towards Correct Variability Analysis of Unpreprocessed C Code for Software Product Lines

TypeChef: Towards Correct Variability Analysis of Unpreprocessed C Code for Software Product Lines TypeChef: Towards Correct Variability Analysis of Unpreprocessed C Code for Software Product Lines Paolo G. Giarrusso 04 March 2011 Software product lines (SPLs) Feature selection SPL = 1 software project

More information

CSCI 123 Introduction to Programming Concepts in C++

CSCI 123 Introduction to Programming Concepts in C++ CSCI 123 Introduction to Programming Concepts in C++ Brad Rippe Brad Rippe More Classes and Dynamic Arrays Overview 11.4 Classes and Dynamic Arrays Constructors, Destructors, Copy Constructors Separation

More information

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version:

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version: SISTEMI EMBEDDED The C Pre-processor Fixed-size integer types Bit Manipulation Federico Baronti Last version: 20160302 The C PreProcessor CPP (1) CPP is a program called by the compiler that processes

More information

What goes inside when you declare a variable?

What goes inside when you declare a variable? Stack, heap, value types, reference types, boxing, and unboxing Introduction This article will explain six important concepts: stack, heap, value types, reference types, boxing, and unboxing. This article

More information

Problem Solving and 'C' Programming

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

Lectures 5-6: Introduction to C

Lectures 5-6: Introduction to C Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most

More information

Due Date: See Blackboard

Due Date: See Blackboard Source File: ~/2305/lab06.(C CPP cpp c++ cc cxx cp) Input: Under control of main function Output: Under control of main function Value: 2 Extend the IntegerSet class from Lab 04 to provide the following

More information

Basic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Announcements Exam 1 (20%): Feb. 27 (Tuesday) Tentative Proposal Deadline:

More information

Parallel Tools Platform for Judge

Parallel Tools Platform for Judge Parallel Tools Platform for Judge Carsten Karbach, Forschungszentrum Jülich GmbH September 20, 2013 Abstract The Parallel Tools Platform (PTP) represents a development environment for parallel applications.

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

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems Deep C Multifile projects Getting it running Data types Typecasting Memory management Pointers Fabián E. Bustamante, Fall 2004 Multifile Projects Give your project a structure Modularized design Reuse

More information

F28069 ControlCard Lab1

F28069 ControlCard Lab1 F28069 ControlCard Lab1 Toggle LED LD2 (GPIO31) and LD3 (GPIO34) 1. Project Dependencies The project expects the following support files: Support files of controlsuite installed in: C:\TI\controlSUITE\device_support\f28069\v135

More information