SlideShare ist ein Scribd-Unternehmen logo
1 von 10
Programming Embedded 
Systems in C++ 
A C to C++ Migration Strategy 
20 May 2014 
Colin Walls, Mentor Graphics 
1
This is what a question slide will 
look like. 
Please answer in the chat. 
Also, questions to me start with ? 
2 
[ # ]
Agenda 
Monday: C++ for Embedded Programming 
Tuesday: C to C++ Migration Strategy 
Wednesday: C++ and a Real Time Operating 
System 
Thursday: Case study #1 
Friday: Case Study #2 
3
What language are you 
using for embedded 
development today? 
4 
[ 1 ]
C to C++ Migration 
• Three stage process: 
– exploit reusability 
• new code in C++ 
• link with C code 
– treat C as C++ 
• clean up C code to comply with C++ 
– start using C++ language features 
5
Apply Reusability 
• All new code in C++ 
– link with existing C modules 
• Problem with typesafe linkage 
– C++ function names and references manged 
fun(int) becomes fun_int(int) 
– C functions not mangled 
fun(int) unchanged 
– use extern "C" 
extern "C" 
{ 
void funx(int); 
int fun(float); 
... 
} 
6
Clean C 
• ANSI C is essentially a subset of C++ 
• Numerous minor exceptions 
• Clean C is true subset 
– code written or modified to accommodate exceptions 
– still ANSI C 
– specific points to address 
• Treat Clean C as if it were C++ 
– acceptable to C++ compiler 
– type-safe linkage OK 
7
Clean C 
• Function prototypes are mandatory 
• Implicit types casts are a problem 
– use explicit – like (char) 
• Enumerated types are taken “seriously” 
• Character arrays must have room for 
terminator 
char str[3] = "xyz"; is not acceptable 
char str[] = "xyz"; is better 
8
Clean C 
C: 
Nested structures need care 
struct out 
{ 
struct in { int i; } m; 
int j; 
}; 
struct in inner; 
struct out outer; 
Clean C: 
struct in { int i; }; 
struct out 
{ 
struct in m; 
int j; 
}; 
struct in inner; 
struct out outer; 
9
To view the rest of this course, 
visit the full recorded version on Design News. 
10

Weitere ähnliche Inhalte

Was ist angesagt?

2014-06-26 - A guide to undefined behavior in c and c++
2014-06-26 - A guide to undefined behavior in c and c++2014-06-26 - A guide to undefined behavior in c and c++
2014-06-26 - A guide to undefined behavior in c and c++
Chen-Han Hsiao
 
情報委員会説明プレゼン@オリエンテーション
情報委員会説明プレゼン@オリエンテーション情報委員会説明プレゼン@オリエンテーション
情報委員会説明プレゼン@オリエンテーション
Takaki Yoneyama
 

Was ist angesagt? (19)

C++ day2
C++ day2C++ day2
C++ day2
 
Write a complete C++ program that does the following: 1. The program will c...
Write a complete C++ program that does the following:   1. The program will c...Write a complete C++ program that does the following:   1. The program will c...
Write a complete C++ program that does the following: 1. The program will c...
 
Unit iv
Unit ivUnit iv
Unit iv
 
C++17 not your father’s c++
C++17  not your father’s c++C++17  not your father’s c++
C++17 not your father’s c++
 
Lecture02
Lecture02Lecture02
Lecture02
 
1 c introduction
1 c introduction1 c introduction
1 c introduction
 
Programs that work in c and not in c
Programs that work in c and not in cPrograms that work in c and not in c
Programs that work in c and not in c
 
Two C++ Tools: Compiler Explorer and Cpp Insights
Two C++ Tools: Compiler Explorer and Cpp InsightsTwo C++ Tools: Compiler Explorer and Cpp Insights
Two C++ Tools: Compiler Explorer and Cpp Insights
 
[Question Paper] Object Oriented Programming With C++ (Revised Course) [April...
[Question Paper] Object Oriented Programming With C++ (Revised Course) [April...[Question Paper] Object Oriented Programming With C++ (Revised Course) [April...
[Question Paper] Object Oriented Programming With C++ (Revised Course) [April...
 
C mcq practice test 1
C mcq practice test 1C mcq practice test 1
C mcq practice test 1
 
2014-06-26 - A guide to undefined behavior in c and c++
2014-06-26 - A guide to undefined behavior in c and c++2014-06-26 - A guide to undefined behavior in c and c++
2014-06-26 - A guide to undefined behavior in c and c++
 
Armstrong calculator
Armstrong calculatorArmstrong calculator
Armstrong calculator
 
Tricks
TricksTricks
Tricks
 
01 basic programming in c++
01 basic programming in c++01 basic programming in c++
01 basic programming in c++
 
[Question Paper] Advanced SQL (Revised Course) [April / 2014]
[Question Paper] Advanced SQL (Revised Course) [April / 2014][Question Paper] Advanced SQL (Revised Course) [April / 2014]
[Question Paper] Advanced SQL (Revised Course) [April / 2014]
 
情報委員会説明プレゼン@オリエンテーション
情報委員会説明プレゼン@オリエンテーション情報委員会説明プレゼン@オリエンテーション
情報委員会説明プレゼン@オリエンテーション
 
C++
C++C++
C++
 
2021 National Poison Prevention Week Poster Showcase
2021 National Poison Prevention Week Poster Showcase2021 National Poison Prevention Week Poster Showcase
2021 National Poison Prevention Week Poster Showcase
 
Compiler lec 3
Compiler lec 3Compiler lec 3
Compiler lec 3
 

Andere mochten auch

Automated Python Test Frameworks for Hardware Verification and Validation
Automated Python Test Frameworks for Hardware Verification and ValidationAutomated Python Test Frameworks for Hardware Verification and Validation
Automated Python Test Frameworks for Hardware Verification and Validation
Barbara Jones
 

Andere mochten auch (8)

C++ and Embedded Linux - a perfect match
C++ and Embedded Linux - a perfect matchC++ and Embedded Linux - a perfect match
C++ and Embedded Linux - a perfect match
 
AUTOMATED TESTING USING PYTHON (ATE)
AUTOMATED TESTING USING PYTHON (ATE)AUTOMATED TESTING USING PYTHON (ATE)
AUTOMATED TESTING USING PYTHON (ATE)
 
Python in Test automation
Python in Test automationPython in Test automation
Python in Test automation
 
Automated Python Test Frameworks for Hardware Verification and Validation
Automated Python Test Frameworks for Hardware Verification and ValidationAutomated Python Test Frameworks for Hardware Verification and Validation
Automated Python Test Frameworks for Hardware Verification and Validation
 
Embedded System Test Automation
Embedded System Test AutomationEmbedded System Test Automation
Embedded System Test Automation
 
Automated hardware testing using python
Automated hardware testing using pythonAutomated hardware testing using python
Automated hardware testing using python
 
Automated Testing for Embedded Software in C or C++
Automated Testing for Embedded Software in C or C++Automated Testing for Embedded Software in C or C++
Automated Testing for Embedded Software in C or C++
 
Automated Regression Testing for Embedded Systems in Action
Automated Regression Testing for Embedded Systems in ActionAutomated Regression Testing for Embedded Systems in Action
Automated Regression Testing for Embedded Systems in Action
 

Ähnlich wie C to C++ Migration Strategy

Review chapter 1 2-3
Review chapter 1 2-3Review chapter 1 2-3
Review chapter 1 2-3
ahmed22dg
 
C++ programming intro
C++ programming introC++ programming intro
C++ programming intro
marklaloo
 

Ähnlich wie C to C++ Migration Strategy (20)

Modern C++ Lunch and Learn
Modern C++ Lunch and LearnModern C++ Lunch and Learn
Modern C++ Lunch and Learn
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
Review chapter 1 2-3
Review chapter 1 2-3Review chapter 1 2-3
Review chapter 1 2-3
 
Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++
 
College1
College1College1
College1
 
C++ programming intro
C++ programming introC++ programming intro
C++ programming intro
 
Effective C++
Effective C++Effective C++
Effective C++
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
C#unit4
C#unit4C#unit4
C#unit4
 
9781285852744 ppt ch02
9781285852744 ppt ch029781285852744 ppt ch02
9781285852744 ppt ch02
 
Return of c++
Return of c++Return of c++
Return of c++
 
C++ for Embedded Programming
C++ for Embedded ProgrammingC++ for Embedded Programming
C++ for Embedded Programming
 
PPT slide_chapter 02 Basic element of C++.ppt
PPT slide_chapter 02 Basic element of C++.pptPPT slide_chapter 02 Basic element of C++.ppt
PPT slide_chapter 02 Basic element of C++.ppt
 
C++.ppt
C++.pptC++.ppt
C++.ppt
 
c++ ppt.ppt
c++ ppt.pptc++ ppt.ppt
c++ ppt.ppt
 
11 cpp
11 cpp11 cpp
11 cpp
 
L6
L6L6
L6
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

C to C++ Migration Strategy

  • 1. Programming Embedded Systems in C++ A C to C++ Migration Strategy 20 May 2014 Colin Walls, Mentor Graphics 1
  • 2. This is what a question slide will look like. Please answer in the chat. Also, questions to me start with ? 2 [ # ]
  • 3. Agenda Monday: C++ for Embedded Programming Tuesday: C to C++ Migration Strategy Wednesday: C++ and a Real Time Operating System Thursday: Case study #1 Friday: Case Study #2 3
  • 4. What language are you using for embedded development today? 4 [ 1 ]
  • 5. C to C++ Migration • Three stage process: – exploit reusability • new code in C++ • link with C code – treat C as C++ • clean up C code to comply with C++ – start using C++ language features 5
  • 6. Apply Reusability • All new code in C++ – link with existing C modules • Problem with typesafe linkage – C++ function names and references manged fun(int) becomes fun_int(int) – C functions not mangled fun(int) unchanged – use extern "C" extern "C" { void funx(int); int fun(float); ... } 6
  • 7. Clean C • ANSI C is essentially a subset of C++ • Numerous minor exceptions • Clean C is true subset – code written or modified to accommodate exceptions – still ANSI C – specific points to address • Treat Clean C as if it were C++ – acceptable to C++ compiler – type-safe linkage OK 7
  • 8. Clean C • Function prototypes are mandatory • Implicit types casts are a problem – use explicit – like (char) • Enumerated types are taken “seriously” • Character arrays must have room for terminator char str[3] = "xyz"; is not acceptable char str[] = "xyz"; is better 8
  • 9. Clean C C: Nested structures need care struct out { struct in { int i; } m; int j; }; struct in inner; struct out outer; Clean C: struct in { int i; }; struct out { struct in m; int j; }; struct in inner; struct out outer; 9
  • 10. To view the rest of this course, visit the full recorded version on Design News. 10