PlatformIO Community

Huge number of ArduionoBLE Lib compiler warnings

I am getting a massive number of compiler warnings (like 47 of 'em) on first compilation of the arduino-libraries/ArduinoBLE library (installed from registry.platformio.org). As only language-level warnings are generated, this just occurs on first compile when the library is initially added to a project (even an empty new project). Obviously I could ignore the warnings (or ini file, build_flags = -w), however, it is mightily disturbing getting such let alone so many warnings - I have to assume I must be doing something wrong. Dozens of PIO/Arduino/Google searches haven’t turned up anything helpful let alone anyone else reporting quite this problem. Also, I have been inactive this last year or so, but previously had no such problem with this library.

Other Arduino libraries (ex: [arduino-libraries/Arduino_LSM9DS1] compile just fine. I can upload and run BLE examples fine. This “warning” problem occurs without fail both on a clean-built MacBook (2010 / High Sierra - MacOS 10.13.6) and a spanking brand new MacBook Air (2020, M1 chip). I have many times deleted / rebuilt ~/.platformio, ~/.vscode, ~/projectpath/.pio, rebuilt the Intellisense index, etc. All to no effect. While not critical (tho’ I have wasted DAYS isolating this), I sure would appreciate some idea of what’s going on and how to rectify it.

platformio.ini file:

[env:nano33ble]
platform = nordicnrf52
board = nano33ble
framework = arduino
lib_deps = arduino-libraries/ArduinoBLE@^1.3.2

main.cpp

#include <Arduino.h>
#include <ArduinoBLE.h>

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

Terminal output:

Executing task: platformio run --environment nano33ble 

Processing nano33ble (platform: nordicnrf52; board: nano33ble; framework: arduino)
-------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/nano33ble.html
PLATFORM: Nordic nRF52 (9.4.0) > Arduino Nano 33 BLE
HARDWARE: NRF52840 64MHz, 256KB RAM, 960KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink)
PACKAGES: 
 - framework-arduino-mbed @ 3.1.1 
 - tool-sreccat @ 1.164.0 (1.64) 
 - toolchain-gccarmnoneeabi @ 1.80201.181220 (8.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 38 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ArduinoBLE @ 1.3.2
Building in release mode
Compiling .pio/build/nano33ble/src/main.cpp.o
Generating LD script .pio/build/nano33ble/cpp.linker_script.ld
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/BLEAdvertisingData.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/BLECharacteristic.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/BLEDescriptor.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/BLEDevice.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/BLEService.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/BLEStringCharacteristic.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/BLETypedCharacteristics.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/local/BLELocalAttribute.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/local/BLELocalCharacteristic.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/local/BLELocalDescriptor.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/local/BLELocalDevice.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/local/BLELocalService.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/remote/BLERemoteAttribute.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/remote/BLERemoteCharacteristic.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/remote/BLERemoteDescriptor.cpp.o
In file included from .pio/libdeps/nano33ble/ArduinoBLE/src/utility/GATT.h:26,
                 from .pio/libdeps/nano33ble/ArduinoBLE/src/local/BLELocalCharacteristic.cpp:25:
.pio/libdeps/nano33ble/ArduinoBLE/src/local/BLELocalCharacteristic.h: In constructor 'BLELocalCharacteristic::BLELocalCharacteristic(const char*, uint16_t, int, bool)':
.pio/libdeps/nano33ble/ArduinoBLE/src/local/BLELocalCharacteristic.h:90:12: warning: 'BLELocalCharacteristic::_cccdValue' will be initialized after [-Wreorder]
   uint16_t _cccdValue;
            ^~~~~~~~~~
.pio/libdeps/nano33ble/ArduinoBLE/src/local/BLELocalCharacteristic.h:79:12: warning:   'uint8_t BLELocalCharacteristic::_permissions' [-Wreorder]
   uint8_t  _permissions;
            ^~~~~~~~~~~~
.pio/libdeps/nano33ble/ArduinoBLE/src/local/BLELocalCharacteristic.cpp:32:1: warning:   when initialized here [-Wreorder]
 BLELocalCharacteristic::BLELocalCharacteristic(const char* uuid, uint16_t permissions, int valueSize, bool fixedLength) :
 ^~~~~~~~~~~~~~~~~~~~~~
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/remote/BLERemoteDevice.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/remote/BLERemoteService.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/utility/ATT.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/utility/BLEUuid.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/utility/GAP.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/utility/GATT.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/utility/HCI.cpp.o
Compiling .pio/build/nano33ble/lib4db/ArduinoBLE/utility/HCICordioTransport.cpp.o
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp: In member function 'virtual bool ATTClass::handleNotify(uint16_t, const uint8_t*, int)':
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp:592:39: warning: variable length array 'notification' is used [-Wvla]
     uint8_t notification[_peers[i].mtu];
                                       ^
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp: In member function 'virtual bool ATTClass::handleInd(uint16_t, const uint8_t*, int)':
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp:623:37: warning: variable length array 'indication' is used [-Wvla]
     uint8_t indication[_peers[i].mtu];
                                     ^
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp: In member function 'virtual void ATTClass::findInfoReq(uint16_t, uint16_t, uint8_t, uint8_t*)':
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp:746:23: warning: variable length array 'response' is used [-Wvla]
   uint8_t response[mtu];
                       ^
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp: In member function 'virtual void ATTClass::findByTypeReq(uint16_t, uint16_t, uint8_t, uint8_t*)':
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp:838:23: warning: variable length array 'response' is used [-Wvla]
   uint8_t response[mtu];
                       ^
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp: In member function 'virtual void ATTClass::readByGroupReq(uint16_t, uint16_t, uint8_t, uint8_t*)':
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp:896:23: warning: variable length array 'response' is used [-Wvla]
   uint8_t response[mtu];
                       ^
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp: In member function 'virtual void ATTClass::readOrReadBlobReq(uint16_t, uint16_t, uint8_t, uint8_t, uint8_t*)':
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp:1003:23: warning: variable length array 'response' is used [-Wvla]
   uint8_t response[mtu];
                       ^
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp: In member function 'virtual void ATTClass::readByTypeReq(uint16_t, uint16_t, uint8_t, uint8_t*)':
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/ATT.cpp:1118:23: warning: variable length array 'response' is used [-Wvla]
   uint8_t response[mtu];
                       ^

[snip...] [deleted portion much the same as above and below]

           
Compiling .pio/build/nano33ble/FrameworkArduino/Tone.cpp.o
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/L2CAPSignaling.cpp: In member function 'virtual void L2CAPSignalingClass::handleSecurityData(uint16_t, uint8_t, uint8_t*)':
.pio/libdeps/nano33ble/ArduinoBLE/src/utility/L2CAPSignaling.cpp:296:13: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
     for(int i; i<6; i++) peerAddress[5-i] = identityAddress->address[i];
             ^
Compiling .pio/build/nano33ble/FrameworkArduino/USB/PluggableUSBDevice.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/USB/USBCDC.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/USB/USBSerial.cpp.o
Archiving .pio/build/nano33ble/lib4db/libArduinoBLE.a
Indexing .pio/build/nano33ble/lib4db/libArduinoBLE.a
Compiling .pio/build/nano33ble/FrameworkArduino/WMath.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/abi.cpp.o
Archiving .pio/build/nano33ble/libFrameworkArduinoVariant.a
Indexing .pio/build/nano33ble/libFrameworkArduinoVariant.a
Compiling .pio/build/nano33ble/FrameworkArduino/api/Common.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/api/IPAddress.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/api/PluggableUSB.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/api/Print.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/api/Stream.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/api/String.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/arm_hal_random.c.o
Compiling .pio/build/nano33ble/FrameworkArduino/as_mbed_library/variant.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/itoa.c.o
Compiling .pio/build/nano33ble/FrameworkArduino/main.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/mbed/platform/cxxsupport/mstd_mutex.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/pinToIndex.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/random_seed.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/timer.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/wiring.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/wiring_analog.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/wiring_digital.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/wiring_pulse.cpp.o
Compiling .pio/build/nano33ble/FrameworkArduino/wiring_shift.cpp.o
Archiving .pio/build/nano33ble/libFrameworkArduino.a
Indexing .pio/build/nano33ble/libFrameworkArduino.a
Linking .pio/build/nano33ble/firmware.elf
Checking size .pio/build/nano33ble/firmware.elf
Building .pio/build/nano33ble/firmware.bin
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  25.8% (used 67536 bytes from 262144 bytes)
Flash: [===       ]  31.5% (used 309876 bytes from 983040 bytes)
==================================== [SUCCESS] Took 16.06 seconds ====================================

No why? Libs are not always written to the highest standard. The issues you are refering to are e.g. also covered in

@maxgerhardt thanks for the reply & for pointing out the prior report. It’s just that I did not have the same massive compilation warnings issue the year ago I briefly used the ArduinoBLE lib nor do I see such warnings from the Arduino IDE (albeit, presumably a different toolchain).

Also, presuming the vast number of warnings is “normal” seems, well, uhm, not right. :wink: Certainly not professional. And this is an Arduino produced library, which would make me further wonder if the issue really is ‘sloppy craftsmanship’, tho’ perhaps my naiveté is showing.

Absent the one report, as strange to me is nary anyone else having mentioned the issue. I have to rather think there’s a setting, compiler flags, a #define or something basic I have wrong and would appreciate understanding the presumed problem better.

PlatformIO for the nordicnrf52 + Arduino combination (which is your nanoble33 case) uses -Wall to activate all warnings

While on the Arduino IDE, the ArduinoCore-mbed’s default warning level is … Well no flag at all :slight_smile:

So people only see the excessive amount of warnings from this library if they turn up the warning settings.

I believe there isn’t even a Arduino IDE → Tools menu setting for this, so it’s even more hidden to the regular developers.

@maxgerhardt, well, THANK YOU so much. So, it turns out it was my naive trust in these things and these masses of warnings are ‘just the way it is’.

But indeed thank you for clarifying the issue. The only thing I could think better would be if the registry noted in a library’s description when the library’s compilation is expected to throw warnings and that they can be safely ignored. But, so it goes. :face_with_diagonal_mouth:

James