Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/12/12 08:05
Read: times


 
#187912 - As far as '51 goes - C++ is still viable
Responding to: ???'s previous message
No. pooled memory isn't irrelevant. And can be needed for even very small devices.

But next thing - the previous post only covers the things where C++ can result in slower or larger code.

It totally ignores the differences where C++ gives advantages at zero cost to the target hardware.

Namespaces (explicit, or use of classes - especially with static members and zero instanced object, or local variables inside blocks) are always good to have. We want locality of reference and as small global name pool as possible.

Type-safe linking is great - the symbol names involved in the linking process just gets augmented with the parameter types and potentially calling convention.

Polymorph functions and operator overloading can make code easier to modify.

Use of references can help in situations where a pointer may not be null. A function that takes a pointer can just as well get NULL as parameter. A function that takes a reference will have the compiler verify that the user has an object - or the user have to be explicitly stupid and play creative games with type casts.

Bundling data and functions into classes gives easier-to-reuse code. It's possible to have a template of a ring buffer and just instantiate it, specifying "uint8" as data type and 32 as number of elements. And another instance with 64 elements of type "alarm_t".

For some reason, people spend too much time trying to find disadvantages with C++ - but the examples found are features the developer don't need to use. And that will not be more efficient in C if the developer really do need similar functionality.

List of 16 messages in thread
TopicAuthorDate
Who the hell uses C++ in embedded systems...            01/01/70 00:00      
   So?            01/01/70 00:00      
   beware of (verbal) inflation.            01/01/70 00:00      
   Not as many as some would think.            01/01/70 00:00      
      2% don't know            01/01/70 00:00      
         Same same            01/01/70 00:00      
         Surveys            01/01/70 00:00      
   Me!            01/01/70 00:00      
      Using tools that only supports C?            01/01/70 00:00      
         Tools and MISRA            01/01/70 00:00      
   C++ "better than C" for embedded systems            01/01/70 00:00      
      as far as the '51 goes            01/01/70 00:00      
         As far as '51 goes - C++ is still viable            01/01/70 00:00      
            class vs source            01/01/70 00:00      
         I did say "smallish"            01/01/70 00:00      
            Overkill?            01/01/70 00:00      

Back to Subject List