K32L2B21:How to complete to call static constructors

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

K32L2B21:How to complete to call static constructors

跳至解决方案
3,312 次查看
rodger_an
Contributor I

Hello,

For C++ project, how to complete the constructors function call in start up file?

0 项奖励
回复
1 解答
3,253 次查看
ErichStyger
Specialist I

Hi @rodger_an ,

not sure if I understood your question. But you might have a look at my blog article on a related subject: https://mcuoneclipse.com/2020/07/11/from-c-to-c-converting-eclipse-c-projekts/

See the section about the C++ startup code.

The thing is that you can call the constructor initialization for global objects in the startup code, but this depends on the standard library used.

I hope this helps,

Erich

在原帖中查看解决方案

0 项奖励
回复
4 回复数
3,254 次查看
ErichStyger
Specialist I

Hi @rodger_an ,

not sure if I understood your question. But you might have a look at my blog article on a related subject: https://mcuoneclipse.com/2020/07/11/from-c-to-c-converting-eclipse-c-projekts/

See the section about the C++ startup code.

The thing is that you can call the constructor initialization for global objects in the startup code, but this depends on the standard library used.

I hope this helps,

Erich

0 项奖励
回复
3,229 次查看
rodger_an
Contributor I

Thank you! ErichS.

Now I know the Cpp start up file . And know how to generate a ld script for C++ project.

rodger_an_0-1639735505362.png

 

0 项奖励
回复
3,263 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi @rodger_an 

You can create a function which call the constructor in main.c. Then call this function in startup file. This function must be called after everything initialized.

 

Regards,

Jing 

0 项奖励
回复
3,227 次查看
rodger_an
Contributor I

Hi JINGPAN,

Thanks for your direction.

 

0 项奖励
回复