Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

c++ language for AVR?

Status
Not open for further replies.

7rots51

Advanced Member level 4
Joined
May 17, 2002
Messages
1,183
Helped
25
Reputation
50
Reaction score
12
Trophy points
1,318
Activity points
9,636
intitle:c++ language inurl:viewtopic

Hi
If we use C/C++ IAR compiler for AVR.

What is the advantage of using c++ object oriented programming for AVR embedded designs?Can it solve some problems easily that is difficult to solve with C?Does c++ reduces the number of program lines?

what is your experience? :?

Regards
 

avr c oop

In my oppinion (but i'm not speaking out of experience with C++ in AVR) it's dangerous to use C++ for uC's. I guess the biggest problem is Memory allocation! You need to keep track of the memory you use since it's probably limited.
I also think code size is a bit bigger (after compilation, perhaps you can write smaller code) but this is an assumption.
I think if you're gonna use operator overloading, templates, streams, Inheritance with virtual functions, ... you have to have a good idea of what your doing. (If there is a C++ compiler for AVR that supports these things) Small memories are probably the biggest enemy of Object Oriented design.
For the moment i try use only a subset of the C standard library for AVR, eg not the scanf or sprintf methods since they increase compiled code size allot (3 to 5 kB)

Antharax
 

scanf iar avr

a couple of months ago I started with AVR and c++. It's rather painful adventure, but now most of things seems to work. So I decided to share my little experience, maybe it will be useful for you.
 

object oriented avr

stevejack have you tried C++ coding for AVR in IAR compiler?
 

In my oppinion (but i'm not speaking out of experience with C++ in AVR) it's dangerous to use C++ for uC's. I guess the biggest problem is Memory allocation! You need to keep track of the memory you use since it's probably limited.
I also think code size is a bit bigger (after compilation, perhaps you can write smaller code) but this is an assumption.
I think if you're gonna use operator overloading, templates, streams, Inheritance with virtual functions, ... you have to have a good idea of what your doing. (If there is a C++ compiler for AVR that supports these things) Small memories are probably the biggest enemy of Object Oriented design.
For the moment i try use only a subset of the C standard library for AVR, eg not the scanf or sprintf methods since they increase compiled code size allot (3 to 5 kB)
Why would C++ be more memory intensive than C? It works exactly like C when compiled so the difference would be close to none.

Also, why would memory allocation be a bigger problem in C++ than it is in C? After all newlib uses the same procedures to allocate memory with C++ as it does in C. You can use stack allocation in C++ too despite it being rather limiting.

Simon
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top