HI,i want use __weak to define function and create a project like follow:
in file main.c
void weakFunctioin(void){ logInfo("print nonWeakFunction\r\n"); return; } int main(void){ logInit(logLevelDebug); logInfo("Build @ %s %s,system start\r\n", __DATE__, __TIME__); weakFunctionTest(1); logInfo("Build @ %s %s,system stop\r\n", __DATE__, __TIME__); while(1); return 0; }
in file weakTest.c
__weak void weakFunctioin(void){ //define as __weak logInfo("print weakFunction\r\n"); } int weakFunctionTest(unsigned int tst){ logInfo("print A\r\n"); if (tst) { logInfo("print B\r\n"); weakFunctioin(); logInfo("print C\r\n"); }else{ logInfo("print D\r\n"); } logInfo("print E\r\n"); return 0; }
and print as follow: -I: Build @ Jun 12 2017 15:14:18,system start -I: print A -I: print B -I: print nonWeakFunction -I: print C -I: print E -I: Build @ Jun 12 2017 15:14:18,system stop
it run OK,BUT when add a dead loop in __weak function in file weakTest.c like as
__weak void weakFunctioin(void){ //define as __weak logInfo("print weakFunction\r\n"); while(1); }
print as follow; -I: Build @ Jun 12 2017 15:14:46,system start -I: print A -I: print B -I: print nonWeakFunction -I: print D //ERROR ERROR ERROR -I: print E -I: Build @ Jun 12 2017 15:14:46,system stop it print "-I: print D" and like branch is error. can anyone tell what's happen. thx.
MDK-ARM version:5.21a MCU: stm32L431RCT6 compiler cmd:--c99 -c --cpu Cortex-M4.fp -D__MICROLIB -g -O0 --apcs=interwork --split_sections -IC:/Users/Administrator/Desktop/weakTest/RTE