Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork213
Description
Problem
Thepins_arduino.h
header is not included byArduino.h
wheneverARDUINO_LIBRARY_DISCOVERY_PHASE == 1
. As a result, sketches and libraries that rely on the macros defined inpins_arduino.h
fail to build during the library discovery phase.
Reproduction
#ifndef NUM_DIGITAL_PINS#error "NUM_DIGITAL_PINS not defined"#endifvoidsetup() {}voidloop() {}
Using board 'nano33ble' from platform in folder: /home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1Using core 'arduino' from platform in folder: /home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1Detecting libraries used.../home/pieter/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -c -w -g -Os -nostdlib @/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/variants/ARDUINO_NANO33BLE/defines.txt @/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/variants/ARDUINO_NANO33BLE/cxxflags.txt -DARDUINO_ARCH_NRF52840 -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -w -x c++ -E -CC -DARDUINO=10813 -DARDUINO_ARDUINO_NANO33BLE -DARDUINO_ARCH_MBED -DARDUINO_LIBRARY_DISCOVERY_PHASE=0 -I/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/cores/arduino -I/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/variants/ARDUINO_NANO33BLE -I/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/cores/arduino/api/deprecated -iprefix/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/cores/arduino @/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/variants/ARDUINO_NANO33BLE/includes.txt /tmp/arduino_build_584601/sketch/NUM_DIGITAL_PINS_test.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASEError while detecting libraries included by /tmp/arduino_build_584601/sketch/NUM_DIGITAL_PINS_test.ino.cppGenerating function prototypes.../home/pieter/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -c -w -g -Os -nostdlib @/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/variants/ARDUINO_NANO33BLE/defines.txt @/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/variants/ARDUINO_NANO33BLE/cxxflags.txt -DARDUINO_ARCH_NRF52840 -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -w -x c++ -E -CC -DARDUINO=10813 -DARDUINO_ARDUINO_NANO33BLE -DARDUINO_ARCH_MBED -DARDUINO_LIBRARY_DISCOVERY_PHASE=0 -I/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/cores/arduino -I/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/variants/ARDUINO_NANO33BLE -I/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/cores/arduino/api/deprecated -iprefix/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/cores/arduino @/home/pieter/.arduino15/packages/arduino/hardware/mbed/1.3.1/variants/ARDUINO_NANO33BLE/includes.txt /tmp/arduino_build_584601/sketch/NUM_DIGITAL_PINS_test.ino.cpp -o /tmp/arduino_build_584601/preproc/ctags_target_for_gcc_minus_e.cpp -DARDUINO_LIB_DISCOVERY_PHASENUM_DIGITAL_PINS_test:2:2: error: #error "NUM_DIGITAL_PINS not defined" #error "NUM_DIGITAL_PINS not defined" ^~~~~
This code does compile correctly on other Arduino Cores, such as AVR, SAMD, Teensy, ESP32, etc. It also works in version 1.8.9 of the IDE because it doesn't defineARDUINO_LIBRARY_DISCOVERY_PHASE
.
Use cases
My specific use case is having a library conditionally include code based on the number of pins a specific board has, using theNUM_DIGITAL_PINS
macro.
Thepins_arduino.h
header contains mostly macros, so in my opinion it should be possible to use these macros in#ifdef
s, which is not the case right now.
Proposed solution
Always includepins_arduino.
inArduino.h
, regardless of the value ofARDUINO_LIBRARY_DISCOVERY_PHASE
.