C++ dynamic memory (new/delete) used in MQX with the IAR compiler

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C++ dynamic memory (new/delete) used in MQX with the IAR compiler

1,019 Views
bed
Contributor II

Hi everyone,

 

I am using the IAR C++ compiler with MQX 3.7 and the code that is being ported uses containers which, therefore, use dynamic memory (for C++ new/delete). Is there an easy way to:

- hook up the new/delete - malloc/free to the MQX memory objects, OR

- use a separate heap for the C++ new/deletes

 

Has anyone tackled this before and which way did you go?

 

The device that this is running on has sufficient memory, it's just that we want to use the code with minimal changes.

 

Thanks,

Brian

0 Kudos
Reply
1 Reply

560 Views
OldNick
Contributor IV

Hi,

IAR support are the guys to answer this - they are really good.  when I bumped into this I didn't understand it at all.

 

Now, there are three possible problems which I am aware of.

 

1. new/delete during runtime

2. Static object constructors

3. exception handling

 

The way we have got through is:-

 

1. overload operators new and delete with mqx alloc and dealloc functions.

2. Override the C++ startup, then do static constructors later (when MQX is up and running)  (MQX documentation briefly mentions this

3. Don't use exceptions.

 

Good luck.