Skip to content

Unused variable warning on ESP8266 #381

Open
@nyanpasu64

Description

@nyanpasu64

Describe the bug
On platforms other than ESP32, I get an unused variable warning in the SSD1306Wire constructor, since only the ARDUINO_ARCH_ESP32 branch references the _i2cBus parameter.

To Reproduce
Steps to reproduce the behavior:

  1. Enable warnings in Arduino. V1 instructions: Preferences > Compiler warnings > All.
  2. Build an ESP8266 (not ESP32) project including SSD1306Wire.h.

Sample code
Provide a MCVE below.

#include "SSD1306Wire.h"

Expected behavior
No compiler warning. Perhaps mark the parameter [[maybe_unused]] (since C++17), or add a (void)_i2cBus statement, either in the #if !defined(ARDUINO_ARCH_ESP32) branch or globally?

Screenshots
If applicable, add screenshots to help explain your problem.

SSD1306Wire(uint8_t _address, int _sda = -1, int _scl = -1, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64, HW_I2C _i2cBus = I2C_ONE, int _frequency = 700000) {
setGeometry(g);
this->_address = _address;
this->_sda = _sda;
this->_scl = _scl;
#if !defined(ARDUINO_ARCH_ESP32)
this->_wire = &Wire;
#else
this->_wire = (_i2cBus==I2C_ONE) ? &Wire : &Wire1;
#endif

In file included from /home/nyanpasu64/Documents (Shared)/gbs-c/gbs-control/gbs-control.ino:22:
/home/nyanpasu64/Arduino/libraries/esp8266-oled-ssd1306-master/src/SSD1306Wire.h: In constructor 'SSD1306Wire::SSD1306Wire(uint8_t, int, int, OLEDDISPLAY_GEOMETRY, HW_I2C, int)':
/home/nyanpasu64/Arduino/libraries/esp8266-oled-ssd1306-master/src/SSD1306Wire.h:70:114: warning: unused parameter '_i2cBus' [-Wunused-parameter]
   70 |     SSD1306Wire(uint8_t _address, int _sda = -1, int _scl = -1, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64, HW_I2C _i2cBus = I2C_ONE, int _frequency = 700000) {
      |                                                                                                           ~~~~~~~^~~~~~~~~~~~~~~~~

Versions (please complete the following information):

  • Library: e2e063a (though unchanged in master f96fd6a)
  • Platform: ESP8266 Arduino 3.1.1

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions