espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.76k stars 743 forks source link

Fixing SPI_COUNT multiple defines #2466

Closed brendena closed 7 months ago

brendena commented 7 months ago

When you're building something that has different number of SPI_COUNTS from the expect SPI_COUNTS you get a lot of errors. Enough errors that it makes the terminal hard to tell what's happens.

You can see this when you build for the NRF52832DK

Your screen gets covered with redefinition errors

In file included from targetlibs/nrf5x_12/components/drivers_nrf/hal/nrf_peripherals.h:59,
                 from targetlibs/nrf5x_12/components/drivers_nrf/hal/nrf_gpio.h:44,
                 from targets/nrf5x/nrf5x_utils.h:22,
                 from targets/nrf5x/bluetooth.c:26:
targetlibs/nrf5x_12/components/device/nrf52832_peripherals.h:144: warning: "SPI_COUNT" redefined
  144 | #define SPI_COUNT 3
      |
In file included from /home/brendena/code/newCode/Espruino/src/jsutils.h:17,
                 from /home/brendena/code/newCode/Espruino/src/jspin.h:21,
                 from /home/brendena/code/newCode/Espruino/libs/bluetooth/jswrap_bluetooth.h:14,
                 from targets/nrf5x/bluetooth.c:18:
gen/platform_config.h:40: note: this is the location of the previous definition
   40 | #define SPI_COUNT 1

This is because the nordic SDK also uses the same define.
So my thought is either changing the name of the SPI_COUNT. Or putting if defines around the nordic SDK files. Which since there not getting updated anymore. Would also be a easy fix.

gfwilliams commented 7 months ago

I think it's best to rename SPI_COUNT to ESPR_SPI_COUNT (but to do the same for I2C_COUNT and USART_COUNT) and then at least the chances of name conflicts are much less...