Hello, I am working in a project where I keep code organized in files depending on which external or internal hardware they initialize or use. I am beginning to learn about the possible benefits of inline functions, so I am trying to declare as inline the init functions I have written for each hardware driver.
I am still a bit confused, so pleasee correct me if I am wrong in my understanding of how to declare inline functions. First of all, I have read that inline functions need to be implemented in the header file (as per Standard C++).
The init function I am transforming to inline attaches an ISR so I had to bring the ISR code to the header file too. But when I compile, I get these error messages:
.pio\build\uno\src\maquinas_estado\control_alarma.cpp.o (symbol from plugin): In function handle_STATE_ALARM_DO_BEEP(tag_alarm_controller*, tag_event const*)': (.text+0x0): multiple definition of
ISR_generateTick()’
.pio\build\uno\src\main.cpp.o (symbol from plugin):(.text+0x0): first defined here
.pio\build\uno\src\maquinas_estado\control_timer.cpp.o (symbol from plugin): In function handle_STATE_TIMER_IDLE(tag_timer_controller*, tag_event const*)': (.text+0x0): multiple definition of
ISR_generateTick()’
.pio\build\uno\src\main.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\uno\firmware.elf] Error 1
So, it seems it is having a problem with having the ISR code in the header file. I would like to know what would be the correct way to do what I am trying to do.
This is how the header file is looking right now:
Everything below the “Public function prototypes” was inside the *.cpp file. The only exception is the commented out line
//inline void timeBase_init(void);
that was originally
void timeBase_init(void);
before I tried to play with inline declarations.
Thanks a lot for your help!