[sdiy] how to learn C?

Paul Cunningham paul at cometway.com
Sat Jan 8 22:20:18 CET 2011


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

On Jan 8, 2011, at 3:37 PM, Matthew Smith <matt at smiffytech.com> wrote:

> As regards C++, not if you're doing embedded. As someone just pointed
> out, excellent way to make bloat



More information about the Synth-diy mailing list