how to use new in a constructor then create a global object of class

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

how to use new in a constructor then create a global object of class

443 Views
josephxavier
Contributor III

I am using codewarrior MCU 10.4 , mqx4.0, k20d72m board ,EWL

 

I am attaching my program(cplus.cpp) , I need to use new in constructor then create a global object of class , when I do this my code crashes

 

 

I tried to edit the startup but my changes doesn't come to effect (when debugging the debugger goes into the commented function )

what are the steps to edit startup.c ?

(I tried to comment " bl __call_static_initializers " )

 

 

then I tried to give static heap by adding

"

__SP_INIT = . + 0x00004000;

 

__heap_addr = __SP_INIT;

 

__heap_size = 0x00004000;   "

 

 

to my linker file but it didn't work  I am attaching my linker file (un edited one ).

 

 

how can I add static heap to this linker file  what are the changes to be made ?

Original Attachment has been moved to: cplus.cpp.zip

Original Attachment has been moved to: intflash.lcf.zip

Labels (1)
0 Kudos
Reply
1 Reply

334 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Joseph,

It would be helpful to know what are you trying to achieve, could you give us more information? do you want to use the malloc() function in your MQX project?

Best Regards,

Carlos Mendoza

Technical Support Engineer

0 Kudos
Reply