Follow Us
Categories
Archives
- February 2024
- January 2024
- August 2023
- December 2022
- November 2022
- October 2022
- February 2022
- October 2021
- September 2021
- August 2021
- July 2021
- June 2021
- May 2021
- January 2021
- November 2020
- October 2020
- August 2020
- April 2020
- February 2020
- January 2020
- October 2019
- September 2019
- July 2019
- May 2019
- April 2019
- March 2019
- February 2019
- January 2019
- December 2018
- October 2018
- September 2018
- August 2018
- July 2018
- April 2018
- February 2018
- January 2018
- December 2017
- November 2017
- October 2017
- September 2017
- August 2017
- July 2017
- June 2017
- May 2017
- April 2017
- March 2017
- February 2017
- January 2017
- December 2016
- November 2016
- October 2016
- September 2016
- August 2016
- July 2016
- April 2016
- January 2016
- December 2015
- November 2015
- October 2015
- September 2015
- August 2015
- July 2015
- June 2015
- May 2015
- January 2015
- December 2014
- November 2014
- October 2014
- September 2014
- August 2014
- July 2014
- June 2014
- May 2014
- April 2014
- March 2014
- February 2014
- January 2014
- November 2013
- September 2013
- August 2013
- July 2013
- June 2013
- May 2013
- April 2013
- February 2013
- January 2013
- November 2012
- October 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- December 2011
- November 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
Tag Archives: C++11
Working with Strings in Embedded C++
Director at Feabhas Limited
Co-Founder and Director of Feabhas since 1995.
Niall has been designing and programming embedded systems for over 30 years. He has worked in different sectors, including aerospace, telecomms, government and banking.
His current interest lie in IoT Security and Agile for Embedded Systems.
Niall has been designing and programming embedded systems for over 30 years. He has worked in different sectors, including aerospace, telecomms, government and banking.
His current interest lie in IoT Security and Agile for Embedded Systems.
Latest posts by Niall Cooling (see all)
- Navigating Memory in C++: A Guide to Using std::uintptr_t for Address Handling - February 22, 2024
- Embedded Expertise: Beyond Fixed-Size Integers; Exploring Fast and Least Types - January 15, 2024
- Disassembling a Cortex-M raw binary file with Ghidra - December 20, 2022
In this post, by Embedded I’m generally referring to deeply embedded/bare-metal systems as opposed to Linux-based embedded systems.
Embedded systems and strings
Historically, the need for and thus the use of strings in embedded systems was fairly limited. However, this has changed with the advent of cheaper, full graphic displays and the growth of the ‘Internet of Things’ (IoT).
Many embedded systems sport full-colour graphics displays, supported by embedded-specific graphics libraries, including:
free open-source – e.g. LVGL
vendor-specific – e.g. TouchGFX from STMicroelectronics
fully specialised graphics […]
TDD with Compiler Explorer
Director at Feabhas Limited
Co-Founder and Director of Feabhas since 1995.
Niall has been designing and programming embedded systems for over 30 years. He has worked in different sectors, including aerospace, telecomms, government and banking.
His current interest lie in IoT Security and Agile for Embedded Systems.
Niall has been designing and programming embedded systems for over 30 years. He has worked in different sectors, including aerospace, telecomms, government and banking.
His current interest lie in IoT Security and Agile for Embedded Systems.
Latest posts by Niall Cooling (see all)
- Navigating Memory in C++: A Guide to Using std::uintptr_t for Address Handling - February 22, 2024
- Embedded Expertise: Beyond Fixed-Size Integers; Exploring Fast and Least Types - January 15, 2024
- Disassembling a Cortex-M raw binary file with Ghidra - December 20, 2022
Compiler Explorer (CE) has been around for several years now. When it first appeared on the scene, it immediately became an invaluable tool. Its ability to show generated assembler from given source code across many different compilers and ISAs (Instruction Set Architectures) is “mind-blowing”. We use it extensively when teaching as it allows you to clarify the effect your code can have on both performance and memory usage.
However, rather than limiting itself to only showing generated assembler, recent developments include the […]
Posted in Agile, C/C++ Programming, Testing
Tagged C++, C++11, Catch2, Compiler Explorer, doctest, GoogleTest, Modern C++, Testing
Leave a comment
Contract killing (in Modern C++)
Technical Consultant at Feabhas Ltd
Glennan is an embedded systems and software engineer with over 20 years experience, mostly in high-integrity systems for the defence and aerospace industry.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
Latest posts by Glennan Carnie (see all)
- Practice makes perfect, part 3 – Idiomatic kata - February 27, 2020
- Practice makes perfect, part 2– foundation kata - February 13, 2020
- Practice makes perfect, part 1 – Code kata - January 30, 2020
If you work in high-integrity or safety-critical software then you have a duty-of-care to:
Ensure your code does what it should
Ensure your code doesn’t do what it’s not supposed to.
Moreover, you’re typically required to both demonstrate and document how you’ve achieved this duty-of-care. Typical mechanisms for demonstrating compliance include unit testing and static analysis; documentation usually includes function specifications and test results. The amount of testing, static analysis and documentation you (have to) do depends on the integrity level of your […]
Posted in C/C++ Programming
Tagged assert, attributes, C++11, C++14, C++17, C++20, C++2a, Contracts, deprecated, ensures, expects, maybe_unused, Modern C++, nodiscard, noreturn
3 Comments
Brace initialization of user-defined types
Technical Consultant at Feabhas Ltd
Glennan is an embedded systems and software engineer with over 20 years experience, mostly in high-integrity systems for the defence and aerospace industry.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
Latest posts by Glennan Carnie (see all)
- Practice makes perfect, part 3 – Idiomatic kata - February 27, 2020
- Practice makes perfect, part 2– foundation kata - February 13, 2020
- Practice makes perfect, part 1 – Code kata - January 30, 2020
Uniform initialization syntax is one of my favourite features of Modern C++. I think it’s important, in good quality code, to clearly distinguish between initialization and assignment.
When it comes to user-defined types – structures and classes – brace initialization can throw up a few unexpected issues, and some counter-intuitive results (and errors!).
In this article, I want to have a look at some of the issues with brace initialization of user-defined types – specifically, brace elision and initializer_lists.
Read on for more…
Like (4)
Posted in C/C++ Programming, General
Tagged brace elision, brace initializer syntax, C++11, C++14, C++17, initialization, Modern C++, std::initializer_list
1 Comment
Your handy cut-out-and-keep guide to std::forward and std::move
Technical Consultant at Feabhas Ltd
Glennan is an embedded systems and software engineer with over 20 years experience, mostly in high-integrity systems for the defence and aerospace industry.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
Latest posts by Glennan Carnie (see all)
- Practice makes perfect, part 3 – Idiomatic kata - February 27, 2020
- Practice makes perfect, part 2– foundation kata - February 13, 2020
- Practice makes perfect, part 1 – Code kata - January 30, 2020
I love a good ‘quadrant’ diagram. It brings me immense joy if I can encapsulate some wisdom, guideline or rule-of-thumb in a simple four-quadrant picture.
This time it’s the when-and-where of std::move and std::forward. In my experience, when programmers are first introduced to move semantics, their biggest struggle is to know when (or when not) to apply std::move or std::forward. Usually, it’s a case of “keep apply std::move until it compiles”. I’ve been there myself.
To that end I’ve put together a […]
Posted in C/C++ Programming
Tagged C++, C++0x, C++11, C++1y, Modern C++. C++11. C++14, move policy, move semantics, resource management
2 Comments
“May Not Meet Developer Expectations” #77
Technical Consultant at Feabhas Ltd
Glennan is an embedded systems and software engineer with over 20 years experience, mostly in high-integrity systems for the defence and aerospace industry.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
Latest posts by Glennan Carnie (see all)
- Practice makes perfect, part 3 – Idiomatic kata - February 27, 2020
- Practice makes perfect, part 2– foundation kata - February 13, 2020
- Practice makes perfect, part 1 – Code kata - January 30, 2020
Question: Does the following compile?
int func()
{
int (func);
return
Posted in C/C++ Programming
Tagged C++11, C++14, debugging, declaration, Modern C++, multi-threading
3 Comments
Exceptional fun!
Technical Consultant at Feabhas Ltd
Glennan is an embedded systems and software engineer with over 20 years experience, mostly in high-integrity systems for the defence and aerospace industry.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
Latest posts by Glennan Carnie (see all)
- Practice makes perfect, part 3 – Idiomatic kata - February 27, 2020
- Practice makes perfect, part 2– foundation kata - February 13, 2020
- Practice makes perfect, part 1 – Code kata - January 30, 2020
In this article I want to look at some applications for one of C++’s more obscure mechanisms, the function
Posted in C/C++ Programming
Tagged C++03, C++11, C++14, exceptions, function try-block, goto, Modern C++
3 Comments
Making things do stuff – Part 9
Technical Consultant at Feabhas Ltd
Glennan is an embedded systems and software engineer with over 20 years experience, mostly in high-integrity systems for the defence and aerospace industry.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
Latest posts by Glennan Carnie (see all)
- Practice makes perfect, part 3 – Idiomatic kata - February 27, 2020
- Practice makes perfect, part 2– foundation kata - February 13, 2020
- Practice makes perfect, part 1 – Code kata - January 30, 2020
As a final instalment in this series on hardware manipulation I thought I’d revisit read-only and write-only register types.
Using tag dispatch is not the only way to solve the read- or write-only Register problem. For completeness let’s explore two other alternatives – SFINAE and constexpr if.
For these examples I’m going to use a simplified version of our Register class. I’m ignoring the bit proxy class and using a reduced API. Once understood, the techniques below can be applied to these […]
Posted in C/C++ Programming, Design Issues
Tagged C++, C++0x, C++11, C++1y, constexpr-if, GPIO, hardware manipulation, Modern C++, SFINAE, tag dispatch, Templates
1 Comment
Making things do stuff – Part 7
Technical Consultant at Feabhas Ltd
Glennan is an embedded systems and software engineer with over 20 years experience, mostly in high-integrity systems for the defence and aerospace industry.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
Latest posts by Glennan Carnie (see all)
- Practice makes perfect, part 3 – Idiomatic kata - February 27, 2020
- Practice makes perfect, part 2– foundation kata - February 13, 2020
- Practice makes perfect, part 1 – Code kata - January 30, 2020
In our previous article we explored using templates to build a generic ‘register’ type to allow programmers to access hardware without all the nasty syntax of integer-to-pointer casting, etc.
At the moment, this class gives us little extra functionality beyond cleaning up the syntax (although, in its favour, it also doesn’t incur any additional run-time cost/performance).
In this article we’re going to extend our design to consider special hardware register types – notably read-only and write-only registers – and see how we can […]
Posted in C/C++ Programming
Tagged C++, C++0x, C++11, C++1y, hardware manipulation, Modern C++. C++11. C++14, Templates
2 Comments
Making things do stuff – Part 6
Technical Consultant at Feabhas Ltd
Glennan is an embedded systems and software engineer with over 20 years experience, mostly in high-integrity systems for the defence and aerospace industry.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
He specialises in C++, UML, software modelling, Systems Engineering and process development.
Latest posts by Glennan Carnie (see all)
- Practice makes perfect, part 3 – Idiomatic kata - February 27, 2020
- Practice makes perfect, part 2– foundation kata - February 13, 2020
- Practice makes perfect, part 1 – Code kata - January 30, 2020
As code designers we tend to eschew specific ‘stove-pipe’ code in favour of reusable code elements. Up until now we’ve been coding some very specific examples so it’s probably worth looking at some more generic solutions.
In this article we’ll look at building generic register manipulation classes (or, as one commenter referred to them, ‘register proxy’ classes). Here, we’re really exploring code design rather than coding ‘mechanics’. I’m using this to explore some factors like the balance between efficiency, performance and […]
Posted in C/C++ Programming
Tagged C++, C++0x, C++11, C++1y, GPIO, hardware manipulation, Modern C++. C++11. C++14, Templates
3 Comments