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
519 stars 182 forks source link

Getting compiler error related to macro expansion #104

Closed femto-code closed 2 months ago

femto-code commented 2 months ago

I am using the HAL for an embedded application with the STM32 L4XX device family.

When including the Modbus library in the project, I am getting the following compiler error:

In file included from ../Core/Inc/stm32l4xx_hal_conf.h:262,
                 from ../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h:29,
                 from ../Core/Inc/main.h:30,
                 from ../Middlewares/Third_Party/Modbus/Src/Modbus.c:13:
../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_gpio.h:89:47: error: expected ')' before numeric constant
   89 | #define GPIO_PIN_6                 ((uint16_t)0x0040)  /* Pin 6 selected    */
      |                                               ^~~~~~
../Core/Inc/main.h:74:16: note: in expansion of macro 'GPIO_PIN_6'
   74 | #define EN_Pin GPIO_PIN_6
      |                ^~~~~~~~~~
../Middlewares/Third_Party/Modbus/Inc/Modbus.h:184:18: note: in expansion of macro 'EN_Pin'
  184 |         uint16_t EN_Pin;  //!< flow control pin: 0=USB or RS-232 mode, >1=RS-485 mode
      |                  ^~~~~~

I could not find any invalid uses of the said macro. Thanks for any help with this issue!

alejoseb commented 2 months ago

Hi, this is not related to the library at all. It could be related to a small typo in your code somewhere else. It's common that the compiler complains pointing to macros, but that is not quite accurate.