Skip to content

ESP_I2S.h: error: 'int read' redeclared as different kind of entity #9914

Closed
@kowyo

Description

@kowyo

Board

XIAOESP32S3

Device Description

Hardware Configuration

USB connected to Mac

Version

v3.0.1

IDE Name

Arduino IDE

Operating System

macOS 14.5

Flash frequency

80Mhz

PSRAM enabled

yes

Upload speed

115200

Description

@lucasssvaz @me-no-dev I ran the example code in https://docs.espressif.com/projects/arduino-esp32/en/latest/api/i2s.html?highlight=i2s and the output reported error

Sketch

#include <ESP_I2S.h>

const int buff_size = 128;
int available, read;
uint8_t buffer[buff_size];
I2SClass I2S;

void setup() {
  I2S.setPins(5, 25, 26, 35, 0); //SCK, WS, SDOUT, SDIN, MCLK
  I2S.begin(I2S_MODE_STD, 16000, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO);
  I2S.read();
  available = I2S.available();
  if(available < buff_size) {
    read = I2S.read(buffer, available);
  } else {
    read = I2S.read(buffer, buff_size);
  }
  I2S.write(buffer, read);
  I2S.end();
}

void loop() {}

Debug Message

/Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:4:16: error: 'int read' redeclared as different kind of entity
    4 | int available, read;
      |                ^~~~
In file included from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp32-arduino-libs/idf-release_v5.1-442a798083/esp32s3/include/newlib/platform_include/sys/unistd.h:11,
                 from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp-xs3/2302/xtensa-esp32s3-elf/sys-include/unistd.h:4,
                 from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp32-arduino-libs/idf-release_v5.1-442a798083/esp32s3/include/lwip/port/include/lwipopts.h:14,
                 from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp32-arduino-libs/idf-release_v5.1-442a798083/esp32s3/include/lwip/lwip/src/include/lwip/opt.h:51,
                 from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp32-arduino-libs/idf-release_v5.1-442a798083/esp32s3/include/lwip/lwip/src/include/lwip/ip_addr.h:40,
                 from /Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/cores/esp32/IPAddress.h:25,
                 from /Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/cores/esp32/Arduino.h:196,
                 from /private/var/folders/6r/s6_mxzqs2nq3vp6jb2hh8xpr0000gn/T/arduino/sketches/A17C809F49E99F211DA5F2057498F7E6/sketch/firmware.ino.cpp:1:
/Users/kowyo/Library/Arduino15/packages/esp32/tools/esp-xs3/2302/xtensa-esp32s3-elf/sys-include/sys/unistd.h:189:25: note: previous declaration 'int read(int, void*, size_t)'
  189 | _READ_WRITE_RETURN_TYPE read (int __fd, void *__buf, size_t __nbyte);
      |                         ^~~~
/Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino: In function 'void setup()':
/Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:14:20: error: no matching function for call to 'I2SClass::read(uint8_t [128], int&)'
   14 |     read = I2S.read(buffer, available);
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:1:
/Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:81:7: note: candidate: 'virtual int I2SClass::read()'
   81 |   int read();
      |       ^~~~
/Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:81:7: note:   candidate expects 0 arguments, 2 provided
/Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:16:20: error: no matching function for call to 'I2SClass::read(uint8_t [128], const int&)'
   16 |     read = I2S.read(buffer, buff_size);
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~~~
/Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:81:7: note: candidate: 'virtual int I2SClass::read()'
   81 |   int read();
      |       ^~~~
/Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:81:7: note:   candidate expects 0 arguments, 2 provided
/Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:18:21: error: invalid conversion from 'int (*)(int, void*, size_t)' {aka 'int (*)(int, void*, unsigned int)'} to 'size_t' {aka 'unsigned int'} [-fpermissive]
   18 |   I2S.write(buffer, read);
      |                     ^~~~
      |                     |
      |                     int (*)(int, void*, size_t) {aka int (*)(int, void*, unsigned int)}
/Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:65:40: note:   initializing argument 2 of 'size_t I2SClass::write(uint8_t*, size_t)'
   65 |   size_t write(uint8_t *buffer, size_t size);
      |                                 ~~~~~~~^~~~

exit status 1

Compilation error: 'int read' redeclared as different kind of entity

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Area: Peripherals APIRelates to peripheral's APIs.Type: DocumentationIssue pertains to Documentation of Arduino ESP32Type: ExampleIssue is related to specific example.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions