Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By manufwi
#56713 Hi all,
I am trying to compile this piece of code:
Code: Select allbyte tx_buf[BUF_L];
unsigned int tx_buf_start,tx_buf_end=0;
WiFiClient client;
size_t tx_buf_send()
{
  if (client.connected() && (tx_buf_start!=tx_buf_end)) {
    unsigned int end = (tx_buf_start<tx_buf_end) ? tx_buf_end : BUF_L;
    size_t written = client.write((const char*)&tx_buf[tx_buf_start],(size_t)(end-tx_buf_start));
    size_t written_again = 0;
    tx_buf_start+=written;
    if (tx_buf_start >= BUF_L) {
      tx_buf_start = 0;
      written_again = client.write(tx_buf,tx_buf_end);
      tx_buf_start+=written_again;
    }
    return written+written_again;
  } else return 0;
}

The compile error is:
In file included from /home/manu/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/ESP8266WiFi.h:39:0,
from /home/manu/Arduino/huzzah_as_wifi_serial/huzzah_as_wifi_serial.ino:1:
/home/manu/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiClient.h: In instantiation of 'size_t WiFiClient::write(T&, size_t) [with T = unsigned char [512]; size_t = unsigned int]':
/home/manu/Arduino/huzzah_as_wifi_serial/huzzah_as_wifi_serial.ino:75:53: required from here
/home/manu/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiClient.h:123:36: error: request for member 'available' in 'source', which is of non-class type 'unsigned char [512]'
size_t left = source.available();
^
/home/manu/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiClient.h:127:5: error: request for member 'read' in 'source', which is of non-class type 'unsigned char [512]'
source.read(buffer.get(), will_send);

This is compiled in arduino-1.6.12. I tried several casts to force gcc to use the WiFiClient::write(const uint8_t *buf, size_t size); method instead of the template version which gives the compiler error as I have seen that it should fix the compiler error with no luck.
What am I missing here?
TIA,
Emmanuel