Simplifying Concepts.
Accelerating Innovation.

Jacob's Blog

Jacob Beningo
| |

Tips and Tricks – Learning to write portable code using ANSI-C

Embedded software engineers should be interested in writing production software that is portable and reusable.  Societal demands for refreshing embedded systems every 12 – 18 months are quite demanding and starting from scratch for many systems is just not realistic.  As developers we really should be interested in working on the cutting edge and not reinventing the wheel over and over and over again.  One step towards the goal of writing portable software is to learn and understand ANSI-C.

ANSIC

On a weekly basis I am blessed with the opportunity to interact with and help hundreds of embedded software developers through-out the world.  I’ve noticed that as a group, only about 1 in 25 of us has actually read through main portions of the ANSI-C standard. Another 1 in 25 have at least referred to the standard at one point or another.  The other 23 of 25 have never even picked up the standard!

The ANSI-C standard spells out the constructs and tools available to developers using the C language.  The standard provides the toolbox and the description of those tools and how they can be used.  One of the first steps to learning how to write portable software is to pick up the standard and read through it.  There is no reason to read the standard in one sitting but reading a few sections a week and thinking through their application can have a profound effect on understanding how to use the C language.

Once a developer has read through the standard they have the foundational understanding of what constructs are in the standard.  Writing code with any construct outside the standard whether it be a compiler intrinsic or language add-on will be a sticking point to the portability of the software.  The goal will be to avoid non-standard constructs.

Reading through the standard will also allow a developer to gain insights into the areas of the standard that aren’t fully defined for compiler vendors.  Take for example the size of int or structures and bit fields.  The specification of these constructs are ambiguous and once understood the goal will be to avoid their use or at least document why they are required in a certain application.

Writing portable software isn’t trivial and requires many areas of expertise but the first and possibly the most foundational is understanding the ANSI-C standard.  Have you read it?  If not, you may want to start reading through it one bit at a time.

* * *

Struggling to keep your development skills up to date or facing outdated processes that slow down your team, raise costs, and impact product quality?

Here are 4 ways I can help you:

  • Embedded Software Academy: Enhance your skills, streamline your processes, and elevate your architecture. Join my academy for on-demand, hands-on workshops and cutting-edge development resources designed to transform your career and keep you ahead of the curve.
  • Consulting Services: Get personalized, expert guidance to streamline your development processes, boost efficiency, and achieve your project goals faster. Partner with us to unlock your team's full potential and drive innovation, ensuring your projects success.
  • Team Training and Development: Empower your team with the latest best practices in embedded software. Our expert-led training sessions will equip your team with the skills and knowledge to excel, innovate, and drive your projects to success.
  • Customized Design Solutions: Get design and development assistance to enhance efficiency, ensure robust testing, and streamline your development pipeline, driving your projects success.

Take action today to upgrade your skills, optimize your team, and achieve success.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.