[sdiy] how to learn C?
Matthew Smith
matt at smiffytech.com
Sat Jan 8 22:29:10 CET 2011
Quoth Paul Cunningham at 2011-01-09 07:50...
> c++ is fine for embedded as long as you aren't trying to use the c++ runtime library (dynamic memory allocation, new, delete, virtual methods, streams, etal)... c and c++ is compiled the same way when you stick to the c syntax, and c++ supports a few syntax niceities that make allocating local variables more convenient. if u got it u can use it. and -- u can even use classes as long as they are declared in fixed memory or on the stack (again no virtual methods, new, or delete). of course memory and stack space are in limited supply on embedded systems so don't go crazy. avoid recursive algorithms.
>
> the original c++ is a preprocessor called cfront which translates c++ to c and then compiles with regular cc compiler. it made function names longer to encode the class data, but this extra metainformation is discarded by the linker. modern compilers are much better and very efficient -- disassemble your binary if you need to compare. also c can be explicitly within in c++ if there is a good reason for doing that. and most c/c++ compilers support inline assembly if they can't get the job done at a higher level. -pc
Yay! Thanks for getting me/us up to date on that. A far more technical
explanation than the "don't do it, it makes bloat" I've had hammered
into me.
Took me long enough to get the message that a decent C compiler can make
code just as efficient (if not better) than the average Joe hand-coding
assembly. (Which I took as an excuse to avoid assembly like the plague ;-)
--
Matthew Smith
Smiffytech - Technology Consulting & Web Application Development
Business: http://www.smiffytech.com/
Blog/personal: http://www.smiffysplace.com/
LinkedIn: http://www.linkedin.com/in/smiffy
Skype: msmiffy
Twitter: @smiffy
More information about the Synth-diy
mailing list