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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

1,707件の閲覧回数
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,674件の閲覧回数
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 件の賞賛
返信