Ethernet.h lib error conflicting return type specified for 'virtual size_t...'

Hi Guys,

i'm very new to arduino but i try many things. Right now i'm a bit stucked in a project. I want to connect an EthernetShield and some BS18x20 sensors. I have found a very interesting code online: http://blog.brachium-system.net/archives/105-Arduino-with-Ethernetshield-Get-temperature-via-telnet.html

But when i want to compile this sketch i get some errors:

error: conflicting return type specified for 'virtual void Client::write(uint8_t)'
error: conflicting return type specified for 'virtual size_t EthernetServer::write(const uint8_t*, size_t)'

So what do i need to do in this case? Thanks for any hint you could give to me.

So what do i need to do in this case?

Isn't that obvious? You need to fix the errors.

But when i want to compile this sketch i get some errors:

error: conflicting return type specified for 'virtual void Client::write(uint8_t)'
error: conflicting return type specified for 'virtual size_t EthernetServer::write(const uint8_t*, size_t)'

You get more than that. You get the names of the files that contain the errors. Some library you are using has not been updated to 1.0 standards yet. Since you clipped the name off, we'll have a hard time helping you.

That's true,

so the error says:

That's true,

so the error says:

In file included from arduino-1.0.1\libraries\Ethernet/EthernetClient.h:5,
from arduino-1.0.1\libraries\Ethernet/Ethernet.h:7,
from webserver_mit_1wire.cpp:15:
arduino-1.0.1\libraries\Ethernet/Client.h:15: error: conflicting return type specified for 'virtual void Client::write(uint8_t)'
arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'
arduino-1.0.1\libraries\Ethernet/Client.h:17: error: conflicting return type specified for 'virtual void Client::write(const uint8_t*, size_t)'
arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:50: error: overriding 'virtual size_t Print::write(const uint8_t*, size_t)'
In file included from arduino-1.0.1\libraries\Ethernet/Ethernet.h:7,
from webserver_mit_1wire.cpp:15:
arduino-1.0.1\libraries\Ethernet/EthernetClient.h:17: error: conflicting return type specified for 'virtual size_t EthernetClient::write(uint8_t)'
arduino-1.0.1\libraries\Ethernet/Client.h:15: error: overriding 'virtual void Client::write(uint8_t)'
arduino-1.0.1\libraries\Ethernet/EthernetClient.h:18: error: conflicting return type specified for 'virtual size_t EthernetClient::write(const uint8_t*, size_t)'
arduino-1.0.1\libraries\Ethernet/Client.h:17: error: overriding 'virtual void Client::write(const uint8_t*, size_t)'
In file included from arduino-1.0.1\libraries\Ethernet/EthernetServer.h:4,
from arduino-1.0.1\libraries\Ethernet/Ethernet.h:8,
from webserver_mit_1wire.cpp:15:
arduino-1.0.1\libraries\Ethernet/Server.h:17: error: conflicting return type specified for 'virtual void Server::write(uint8_t)'
arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'
arduino-1.0.1\libraries\Ethernet/Server.h:19: error: conflicting return type specified for 'virtual void Server::write(const uint8_t*, size_t)'
arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:50: error: overriding 'virtual size_t Print::write(const uint8_t*, size_t)'
In file included from arduino-1.0.1\libraries\Ethernet/Ethernet.h:8,
from webserver_mit_1wire.cpp:15:
arduino-1.0.1\libraries\Ethernet/EthernetServer.h:17: error: conflicting return type specified for 'virtual size_t EthernetServer::write(uint8_t)'
arduino-1.0.1\libraries\Ethernet/Server.h:17: error: overriding 'virtual void Server::write(uint8_t)'
arduino-1.0.1\libraries\Ethernet/EthernetServer.h:18: error: conflicting return type specified for 'virtual size_t EthernetServer::write(const uint8_t*, size_t)'
arduino-1.0.1\libraries\Ethernet/Server.h:19: error: overriding 'virtual void Server::write(const uint8_t*, size_t)'

We'll need to see your code, too.

Thanks a lot in advance. This is the code i want to run:

/*
 DS1820 - reads DS1820 sensor and put it onto telnet
 Copyright (C) 2009 Jonas Genannt <jonas@brachium-system.net>

 This program is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
 Free Software Foundation; either version 3 of the License, or (at your option) any later version.
 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 See the GNU General Public License for more details.

 You should have received a copy of the GNU General Public License along with this program;
 if not, see <http://www.gnu.org/licenses/>.
*/
#include <Ethernet.h>
#include <Client.h>
#include <Server.h>
#include <OneWire.h>


#define CONVERT     0x44
#define READSCRATCH 0xBE
// The DS1820 is connected on pin 3
OneWire  ds(3);
Server server = Server(23);
static uint8_t mac[16] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
static uint8_t ip[4]   = { 192, 168,   1, 3 };
static uint8_t gw[4]   = { 192, 168,   1, 1 };
static uint8_t nm[4]   = { 255, 255, 255, 0 };


int  address_index=0;
byte address_storage[64];
void setup()
{
  Serial.begin(9600);
  Ethernet.begin(mac,ip,gw,nm);
  server.begin();
  byte addr[8];
  while(1) {
     if( ! ds.search(addr)) {
       ds.reset_search();
       break;
     }
     else {
       if ( OneWire::crc8( addr, 7) != addr[7] && addr[0] != 0x10)  // CRC Check or is not an DS1820
       {  
         Serial.print("CRC is not valid or device is not an DS1820!\n");
       }
       else {
          Serial.print("Found:");
          for (int i =0; i< 8; i++) {
             address_index++;
             Serial.print(addr[i], HEX);
             Serial.print(":");
             address_storage[address_index]= addr[i];
           }
           Serial.println("");
       }
     }
     delay(10);
  }
  Serial.print("We got ");
  Serial.print((int) (address_index/8) );
  Serial.print(" sensors\n");
}



void getSensorData(char *buffer)
{
  int index = 1;
  Serial.println("In function getSensorData()");
  for (int i=1; i <= (address_index/7); i++) {
    byte addr[8];
    Serial.print("Sensor: ");
    Serial.println(i);
    strcat(buffer, "Sensor:");
    sprintf(buffer, "%s %x",buffer, i);
    strcat(buffer, ": ");
    for (int e =0; e< 8; e++) {
      addr[e] = address_storage[index];
      index++;
    }
    Serial.println("Nach address_storage -> adresse");
    for (int r=0; r<8; r++) {
        char address[10];
        sprintf(address, "%x", addr[r]);
        strcat(buffer, address);
        Serial.print(addr[r],HEX);
    }
    Serial.println("Nach message_data.append(adresse zu hexa; ");
    strcat(buffer, " : ");
    byte present = 0;
    byte data[12];
    // OK we have sensor in addr we read it out!
    ds.reset();
    ds.select(addr);
    ds.write(CONVERT,1);
    delay(1000);
    //delay(750);
    present = ds.reset();                    // Reset device
    ds.select(addr);                         // Select device
    ds.write(READSCRATCH);                   // Read Scratchpad 
    
    for (int b = 0; b < 9; b++) { // get 9 bytes from sensor
      data[b] = ds.read();
    }
    
    if(OneWire::crc8( data, 8) == data[8])  // Check CRC is valid
    {
      // CRC is ok
      float read_temp=((data[1]<<8) | data[0]) >> 1 ;            // Divide the temperature by 2
      float temp_count=float(data[7] - data[6])/(float)data[7];  // Convert to real temperature
      float real_temp = ((float)read_temp-0.25)+temp_count;
      char buff[12];
      tempToAscii(real_temp, buff);
      Serial.println(buff);
      strcat(buffer, buff);
    }
    else {
      Serial.print("Error on CRC8");
      strcat(buffer, "Cound not CRC8 data");
    }
    strcat(buffer, "\n");
   }
}


void loop() {
  
  Client client = server.available();
  if (client) {
    Serial.println("Client has connected");
    char buffer[412]="";
    getSensorData(buffer);
    server.write(buffer);
    client.stop();
  }
    
}

void tempToAscii(double temp, char *buff)
{
  int frac;
  frac=(unsigned int)(temp*1000)%1000;
  itoa((int)temp,buff,10);
  strcat(buff,".");
  itoa(frac,&buff[strlen(buff)],10); //put the frac after the deciaml
}

That code is written for v0023 and earlier. You will need to adapt it to v1.0.1. Just as a test, try compiling this

#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 177);
IPAddress gw(192,168,1, 1);
IPAddress nm(255,255,255,0);

OneWire  ds(3);
EthernetServer server(23);

void setup() {
  Serial.begin(9600);
  Ethernet.begin(mac,ip,gw,gw,nm);
  server.begin();
}

void loop() {
  EthernetClient client = server.available();
  if (client) {
    Serial.println("Client has connected");
    client.stop();
  }
}

It is not operational code. You don't need to upload it. Just verify that it compiles without errors.

Hi and Thanks for your replies.

But unfortunately it doesn't work. Here are the errors:

In file included from  arduino-1.0.1\libraries\Ethernet/EthernetClient.h:5,
                 from  arduino-1.0.1\libraries\Ethernet/Ethernet.h:7,
                 from sketch_may31a.cpp:2:
 arduino-1.0.1\libraries\Ethernet/Client.h:15: error: conflicting return type specified for 'virtual void Client::write(uint8_t)'
 arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'
 arduino-1.0.1\libraries\Ethernet/Client.h:17: error: conflicting return type specified for 'virtual void Client::write(const uint8_t*, size_t)'
 arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:50: error:   overriding 'virtual size_t Print::write(const uint8_t*, size_t)'
In file included from  arduino-1.0.1\libraries\Ethernet/Ethernet.h:7,
                 from sketch_may31a.cpp:2:
 arduino-1.0.1\libraries\Ethernet/EthernetClient.h:17: error: conflicting return type specified for 'virtual size_t EthernetClient::write(uint8_t)'
 arduino-1.0.1\libraries\Ethernet/Client.h:15: error:   overriding 'virtual void Client::write(uint8_t)'
 arduino-1.0.1\libraries\Ethernet/EthernetClient.h:18: error: conflicting return type specified for 'virtual size_t EthernetClient::write(const uint8_t*, size_t)'
 arduino-1.0.1\libraries\Ethernet/Client.h:17: error:   overriding 'virtual void Client::write(const uint8_t*, size_t)'
In file included from  arduino-1.0.1\libraries\Ethernet/EthernetServer.h:4,
                 from  arduino-1.0.1\libraries\Ethernet/Ethernet.h:8,
                 from sketch_may31a.cpp:2:
 arduino-1.0.1\libraries\Ethernet/Server.h:17: error: conflicting return type specified for 'virtual void Server::write(uint8_t)'
 arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'
 arduino-1.0.1\libraries\Ethernet/Server.h:19: error: conflicting return type specified for 'virtual void Server::write(const uint8_t*, size_t)'
 arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:50: error:   overriding 'virtual size_t Print::write(const uint8_t*, size_t)'
In file included from  arduino-1.0.1\libraries\Ethernet/Ethernet.h:8,
                 from sketch_may31a.cpp:2:
 arduino-1.0.1\libraries\Ethernet/EthernetServer.h:17: error: conflicting return type specified for 'virtual size_t EthernetServer::write(uint8_t)'
 arduino-1.0.1\libraries\Ethernet/Server.h:17: error:   overriding 'virtual void Server::write(uint8_t)'
 arduino-1.0.1\libraries\Ethernet/EthernetServer.h:18: error: conflicting return type specified for 'virtual size_t EthernetServer::write(const uint8_t*, size_t)'
 arduino-1.0.1\libraries\Ethernet/Server.h:19: error:   overriding 'virtual void Server::write(const uint8_t*, size_t)'

There is no Client.h file in the IDE v1.0.1 ethernet library.

arduino-1.0.1\libraries\Ethernet/Client.h:15: error: conflicting return type blah blah...

Where did that come from? It is now EthernetClient.h. ??

Thanks a lot for your help. I have no clou what's going on right now. I didn'T change anything in the syste, But now nothing works...

Here are the latest errors, just trying to compile your example...

t Print::write(uint8_t)
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Server.h:6: note: 	virtual void EthernetClient::Server::begin()
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:32: error: ISO C++ forbids initialization of member 'server'
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:32: error: making 'server' static
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:32: error: invalid in-class initialization of static data member of non-integral type 'EthernetClient::Server'
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:33: error: a brace-enclosed initializer is not allowed here before '{' token
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:33: error: invalid in-class initialization of static data member of non-integral type 'uint8_t [16]'
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:34: error: a brace-enclosed initializer is not allowed here before '{' token
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:34: error: invalid in-class initialization of static data member of non-integral type 'uint8_t [4]'
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:35: error: a brace-enclosed initializer is not allowed here before '{' token
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:35: error: invalid in-class initialization of static data member of non-integral type 'uint8_t [4]'
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:36: error: a brace-enclosed initializer is not allowed here before '{' token
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:36: error: invalid in-class initialization of static data member of non-integral type 'uint8_t [4]'
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:39: error: ISO C++ forbids initialization of member 'address_index'
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:39: error: making 'address_index' static
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:39: error: ISO C++ forbids in-class initialization of non-const static member 'address_index'
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h: In member function 'void EthernetClient::setup()':
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:44: error: 'Ethernet' was not declared in this scope
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:44: error: 'mac' was not declared in this scope
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:44: error: 'ip' was not declared in this scope
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:44: error: 'gw' was not declared in this scope
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:44: error: 'nm' was not declared in this scope
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:45: error: 'server' was not declared in this scope
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:48: error: '((EthernetClient*)this)->EthernetClient::ds' does not have class type
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:49: error: '((EthernetClient*)this)->EthernetClient::ds' does not have class type
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h: In member function 'void EthernetClient::getSensorData(char*)':
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:104: error: '((EthernetClient*)this)->EthernetClient::ds' does not have class type
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:105: error: '((EthernetClient*)this)->EthernetClient::ds' does not have class type
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:106: error: '((EthernetClient*)this)->EthernetClient::ds' does not have class type
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:109: error: '((EthernetClient*)this)->EthernetClient::ds' does not have class type
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:110: error: '((EthernetClient*)this)->EthernetClient::ds' does not have class type
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:111: error: '((EthernetClient*)this)->EthernetClient::ds' does not have class type
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:114: error: '((EthernetClient*)this)->EthernetClient::ds' does not have class type
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h: In member function 'void EthernetClient::loop()':
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:139: error: 'server' was not declared in this scope
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:139: error: cannot declare variable 'client' to be of abstract type 'Client'
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:7: note:   because the following virtual functions are pure within 'Client':
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:12: note: 	virtual size_t Client::write(uint8_t)
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:13: note: 	virtual size_t Client::write(const uint8_t*, size_t)
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:14: note: 	virtual int Client::available()
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:15: note: 	virtual int Client::read()
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:17: note: 	virtual int Client::peek()
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:18: note: 	virtual void Client::flush()
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:10: note: 	virtual int Client::connect(IPAddress, uint16_t)
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:11: note: 	virtual int Client::connect(const char*, uint16_t)
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:16: note: 	virtual int Client::read(uint8_t*, size_t)
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:19: note: 	virtual void Client::stop()
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:20: note: 	virtual uint8_t Client::connected()
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:21: note: 	virtual Client::operator bool()
In file included from C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/Ethernet.h:8,
                 from sketch_may31a.cpp:3:
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetServer.h: At global scope:
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetServer.h:9: error: expected class-name before '{' token
C:\Users\doertbud\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetServer.h:19: error: type 'Print' is not a base type for type 'EthernetServer'

Thanks a lot for your help!

I've downloaded the aurduino 1.0.1 IDE once agai and used your sketch! Now it runs perfectly. So now i can adapt the sketch i need.

Thanks! Can