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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

952 次查看
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

标签 (1)
0 项奖励
回复
1 回复

843 次查看
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 项奖励
回复