News for hackers. Stuff that matters.
Re:Object-oriented techniques in C by bliti on Tuesday September 22, 2015 @03:11PM (#10260897)
This is probably a stupid question, but here it goes:

Embedded platforms tend to have size limits. Would this increase the size of the source code? Seems a bit verbose to me.

Re:Object-oriented techniques in C by dimonomid on Tuesday September 22, 2015 @03:17PM (#10260936)
Surely it does have some overhead. And, by the way, passing arguments to function has an overhead as well, comparing to globals. But, how often would you recommend use globals?

The more interesting question is: how much overhead? And the answer is: it depends on the MCU. For example, some 8-bit PICs don't have silicon support for indirect function call (i.e. by function pointer), so they work around this problem by saving function address to the stack and execution 'return' instruction. It works much slower and code size increases notably. I don't use these techniques on these chips.

But for 16- and 32-bit MCUs that I was working with, it works flawlessly. For most of our projects, the overhead is much less significant than the maintainability we get with this approach. As I said in another comment, engineering is all about tradeoffs.

Re:Object-oriented techniques in C by deathanatos on Wednesday September 23, 2015 @02:54AM (#10263663)
> don't have silicon support for indirect function call (i.e. by function pointer), so they work around this problem by saving function address to the stack and execution 'return' instruction.

While no doubt this is true, if you have an indirect function call in C++ OO code, how do you not have it in C? That you had it in C++ implies — I hope — that you needed it. The C code can't simply whisk that need away. (Or, if it can, so can the C++…)

Re:Object-oriented techniques in C by meson2k on Tuesday September 22, 2015 @04:33PM (#10261513)
The size increase by using these techniques would be far smaller than linking in libstdc++. libc is much smaller than libstdc++, especially when you need to support dynamic code and do a whole-archive on your libraries in the executable.