Skip to content

#define MASTER_ADDRESS conflict #1278

Closed
@nschurando

Description

@nschurando

Describe the bug
When compiling a sketch using the tommag/TMC5160_Arduino library, I get a conflit of symbol MASTER_ADDRESS.

The library defines the symbol at TMC5160.h:288 as a private static const which in my opinion is fine.

However the STM32 Arduino core defines the symbol at Wire.h:33 as a preprocessor macro in, which is I believe bad practice since the symbol is only used in the corresponding Wire.cpp source file.

To Reproduce
Install master branch (currently at d220fb5) of tommag/TMC5160_Arduino library, then try to compile the following minimal sketch:

#include <Wire.h>
#include <TMC5160.h>
#include <Arduino.h>
TMC5160_SPI axis_rud = TMC5160_SPI(PC6);
void setup() {}
void loop() {}

Screenshots

"C:\Users\user\AppData\Local\Arduino15\packages\STM32\tools\xpack-arm-none-eabi-gcc\9.2.1-1.1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb "@C:\Users\user\AppData\Local\Temp\arduino_build_81926/sketch/build_opt.h" -c -Os -flto -w -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -fno-use-cxa-atexit -MMD "-IC:\Users\user\sketch_jan13a" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/avr" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/stm32" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/stm32/LL" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/stm32/usb" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/stm32/OpenAMP" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/stm32/usb/hid" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/stm32/usb/cdc" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\system/Drivers/STM32L0xx_HAL_Driver/Inc" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\system/Drivers/STM32L0xx_HAL_Driver/Src" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\system/STM32L0xx" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\system/Middlewares/ST/STM32_USB_Device_Library/Core/Src" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\system/Middlewares/OpenAMP" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\system/Middlewares/OpenAMP/open-amp/lib/include" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\system/Middlewares/OpenAMP/libmetal/lib/include" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\system/Middlewares/OpenAMP/virtual_driver" -DSTM32L0xx -DARDUINO=10810 -DARDUINO_NUCLEO_L073RZ -DARDUINO_ARCH_STM32 "-DBOARD_NAME="NUCLEO_L073RZ"" -DSTM32L073xx -DHAL_UART_MODULE_ENABLED -D__CORTEX_SC=0 "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\tools\CMSIS\5.5.1/CMSIS/Core/Include/" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\system/Drivers/CMSIS/Device/ST/STM32L0xx/Include/" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\system/Drivers/CMSIS/Device/ST/STM32L0xx/Source/Templates/gcc/" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\tools\CMSIS\5.5.1/CMSIS/DSP/Include" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\variants\NUCLEO_L073RZ" "-IC:\Users\user\Documents\Arduino\libraries\SitronLabs_LIS3DH_Arduino_Library\src" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\Wire\src" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\SPI\src" "-IC:\Users\user\Documents\Arduino\libraries\TMC5160_Arduino" "-IC:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\SrcWrapper\src" "C:\Users\user\AppData\Local\Temp\arduino_build_81926\sketch\SrcWrapper.cpp" -o "C:\Users\user\AppData\Local\Temp\arduino_build_81926\sketch\SrcWrapper.cpp.o"
In file included from C:\Users\user\Documents\Arduino\libraries\SitronLabs_LIS3DH_Arduino_Library\src/lis3dh.h:6,
from C:\Users\user\sketch_jan13a\sketch_jan13a.ino:2:
C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\Wire\src/Wire.h:33:24: error: expected unqualified-id before numeric constant
33 | #define MASTER_ADDRESS 0x33
| ^~~~
C:\Users\user\Documents\Arduino\libraries\TMC5160_Arduino/TMC5160.h:288:27: note: in expansion of macro 'MASTER_ADDRESS'
288 | static constexpr uint8_t MASTER_ADDRESS = 0xFF;
| ^~~~~~~~~~~~~~

Desktop (please complete the following information):

  • OS: Windows 10
  • Arduino IDE version: 1.8.10
  • STM32 core version: 1.9.0

Board (please complete the following information):

  • Name: Nucleo 64 L073RZ

Proposed solution
Move the Wire declaration to the Wire.cpp source file, using static constexpr.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions