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

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

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

1,361 Views
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 Kudos
Reply
1 Reply

1,328 Views
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 Kudos
Reply