alejoseb / Modbus-STM32-HAL-FreeRTOS

Modbus TCP and RTU, Master and Slave for STM32 using Cube HAL and FreeRTOS
GNU Lesser General Public License v2.1
539 stars 183 forks source link

Should the variable mHandlers be defined in modbus.h file? #55

Closed kaidegit closed 2 years ago

kaidegit commented 2 years ago

https://github.com/alejoseb/Modbus-STM32-HAL-FreeRTOS/blob/master/MODBUS-LIB/Inc/Modbus.h#L234

The definition in modbus.h causes some compilation errors like multiple definition of 'mHandlers'.

May extern it in modbus.h and define it in modbus.c?

alejoseb commented 2 years ago

It is possible that those errors are reported depending on your particular environment and how the .h file is included. Your solution will work just fine.

kaidegit commented 2 years ago

I think it is very often to include modbus.h at least 2 times, one is in modbus.c and the other is where we use these modbus apis. So may it is ineluctable to cause multiple definition of 'mHandlers'.

alejoseb commented 2 years ago

I updated the library to solve this issue.