Errors when compiling ESP32, "error: 'size_t Print::write(const char*, size_t)' is inaccessible within this context"

Hi everyone ! I’m new here.

I have been using platformIO for my esp32 with no problem for months. But today I needed to change WifiClient to WifiClientSecure because our server got SSL, so i just added #include <WiFiClientSecure.h> and changed the WifiClient client line to WifiClientSecure client

Then this error occured when compiling;

Processing esp32dev (platform: espressif32; board: esp-wrover-kit; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 (4.3.0) > Espressif ESP-WROVER-KIT
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (ftdi) On-board (ftdi) External (cmsis-dap, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
 - framework-arduinoespressif32 @ 3.20003.220626 (2.0.3)
 - tool-esptoolpy @ 1.30300.0 (3.3.0)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 35 compatible libraries
Scanning dependencies...
Dependency Graph
|-- RTClib @ 2.1.1
|   |-- Adafruit BusIO @ 1.14.1
|   |   |-- Wire @ 2.0.0       
|   |   |-- SPI @ 2.0.0        
|   |-- Wire @ 2.0.0
|-- ESP32-PSRamFS @ 1.0.4-beta 
|   |-- FS @ 2.0.0
|-- FS @ 2.0.0
|-- SD @ 2.0.0
|   |-- FS @ 2.0.0
|   |-- SPI @ 2.0.0
|-- WiFi @ 2.0.0
|-- WiFiClientSecure @ 2.0.0
|   |-- WiFi @ 2.0.0
|-- Wire @ 2.0.0
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
src/main.cpp: In function 'bool readPost(fs::FS&, const char*)':
src/main.cpp:374:48: error: 'size_t Print::write(const char*, size_t)' is inaccessible within this context
       written = client.write(fileBuffer, toRead);
In file included from C:/Users/zydiz/.platformio/packages/framework-arduinoespressif32/cores/esp32/Stream.h:26,
                 from C:/Users/zydiz/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:160,
                 from src/main.cpp:9:
C:/Users/zydiz/.platformio/packages/framework-arduinoespressif32/cores/esp32/Print.h:70:12: note: declared here
     size_t write(const char *buffer, size_t size)
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1

When I revert back my changes to plain old WifiClient everything compiles.

The function that generates the error;

  WiFiClientSecure client;
      written = client.write(fileBuffer, toRead);
      log_d("%d", written);
  delete[] fileBuffer;
  return true;

My includes;

#include <Arduino.h>
#include <esp_task_wdt.h>
#include <driver/i2s.h>

#include "sos-iir-filter.h"

#include <WiFi.h>
#include <WiFiClientSecure.h>

#include <bits/stdc++.h>
using namespace std;

#include "FS.h"
#include "SD.h"
#include "PSRamFS.h"

#include <Wire.h>
#include "RTClib.h"

#include "time.h"

My platformio.ini;

platform = espressif32
board = esp-wrover-kit
framework = arduino
monitor_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=5
build_src_filter = +<main.cpp>, -<test.cpp>
monitor_filters = esp32_exception_decoder, log2file
lib_deps = adafruit/RTClib@^2.0.2 
board_build.f_flash = 80000000L

What may be the issue? Though it was some include + platformio.ini stuff that’s why I posted it here in this “PlatformIO IDE” category.

Can you add a cast to const uint8_t* on fileBuffer to make sure it matches the signature

1 Like

Wow, amazingly simple solution thanks a looot. So a simple overload problem?. It has compiled succesfully but there is now another problem. The WifiClient verison was using about 80% flash, but now with this WifiClientSecure version it uses about 90% flash. Is it the library?

Probably. If you want detailed answers you’ll have to use the PlatformIO Inspect tool for memory or load the .pio/build/<env>/<project>.map files into amap to compare the before and after memory usage in detail.

1 Like

Wow again, didn’t know that tool existed. Thank you again so much. Sorry about this question being turned into a C++ question.