Initializzation of global Object in C++ - In K22 Prokject

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

Initializzation of global Object in C++ - In K22 Prokject

1,678 次查看
vdavi81_cefla
Contributor I

Hi,

I'm writing, a software for K22-based board. I have great problem, I'd like to write a global Object. I'm trying to insert them, 

but no constructor runs before main. resulting in the impossibility of initializing the Objects. This creates errors at Run-Time.

i.e. Each Objects, writen below, are defined outside main and Each Object is outside of any method.

tDebIn Interlock(PTB10); /* interlock*/
/*DipSwitch*/
tDebIn DIP_SW1(PTC12);
tDebIn DIP_SW2(PTC13);
tDebIn DIP_SW3(PTC14);
tDebIn DIP_SW4(PTC15);
tDebInAs TRIGGER(PTB11); 

nobody Costructur CLass is executed. What I have to do, to initialize the Object before the main 

goes into execution. 

 

0 项奖励
回复
1 回复

1,645 次查看
ErichStyger
Specialist I

See https://mcuoneclipse.com/2022/10/24/shut-down-c-embedded-systems-with-calling-the-global-destructors... how constructors (and even destructors) are handled from the startup code.

I hope this helps,

Erich

0 项奖励
回复