简体   繁体   中英

Libraries in Arduino IDE 1.0

I have a simple program to test out these libraries after upgrading to version 1. The program is linked below as are the libraries. They are for SHT21 humidity sensors.

I get the following errors when I try to compile the program and libraries.

In file included from sketch_mar26a.cpp:1: /Applications/Arduino v1.0.app/Contents/Resources/Java/libraries/Ports/Ports.h:239: error: conflicting return type specified for 'virtual void UartPlug::write(byte)' /Applications/Arduino v1.0.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'

Offending section from ports.h

public:
UartPlug (PortI2C& port, byte addr)
    : dev (port, addr), in (0), out (0) {}

void begin(long);
byte available();
int read();
void flush();
virtual void write(byte);

Offending line from print.h

    virtual size_t write(uint8_t) = 0;

The problem is that in Arduino 1.0 the Print interface changed to return a number of bytes 'printed' from its write function (previously it didn't return a count). Your function declaration:

virtual void write(byte);

needs to change to:

virtual size_t write(byte); 
// or write(uint8_t) since byte is #defined as uint8_t

and the implementation will need to return the number of bytes written.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM