Search code examples
coopembeddedmicrocontrollerfirmware

Programming a Microprocessor using C in Object Oriented Paradigm, is it Advisable?


Since C is commonly used in micro-controllers and it is possible to do object oriented programming in C, is it advisable to implement object oriented micro-controller programming using C? What are the pros and cons?


Solution

  • As long as you do not need polymorpism it is ok to pass structs around. But as soon as you use polymorphism/virtual function and putting functions inside these structs it might become very cryptic.

    It also depends what you need to do. For drivers you do not need OO, maybe for application. Keep in mind that microcontrolers are low whit RAM, any you will need to keep low RAM footprint all the time in any case.

    If you do not plan to write more than 40k lines of application plain C is good enough and without fancy OO tricks.