1 / 10

Programming Embedded Systems in C++ 

Programming Embedded Systems in C++ . A C to C++ Migration Strategy  . 20 May 2014 Colin Walls, Mentor Graphics. [ # ]. This is what a question slide will look like. Please answer in the chat. Also, questions to me start with ?. Agenda. Monday : C++ for Embedded Programming

Download Presentation

Programming Embedded Systems in C++ 

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Embedded Systems in C++  A C to C++ Migration Strategy   20 May 2014Colin Walls, Mentor Graphics

  2. [ # ] This is what a question slide will look like.Please answer in the chat. Also, questions to me start with ?

  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

  4. [ 1 ] What language are you using for embedded development today?

  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

  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); ... }

  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

  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

  9. Clean C Nested structures need care C: 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;

  10. To view the rest of this course, visit the full recorded version on Design News.

More Related