I am a learning newcomer to Arduino. I am getting compilation errors when using the DS1307 libraries in version 1.0.1 of the IDE:
C:\Program-Arduino\arduino-1.0.1\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -IC:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino -IC:\Program-Arduino\arduino-1.0.1\hardware\arduino\variants\mega -IC:\Program-Arduino\arduino-1.0.1\libraries\Wire -IC:\Program-Arduino\arduino-1.0.1\libraries\DS1307 C:\Users\Ric\AppData\Local\Temp\build7666495859859217241.tmp\DS1307.cpp -o C:\Users\Ric\AppData\Local\Temp\build7666495859859217241.tmp\DS1307.cpp.o
Using previously compiled: C:\Users\Ric\AppData\Local\Temp\build7666495859859217241.tmp\Wire\Wire.cpp.o
Using previously compiled: C:\Users\Ric\AppData\Local\Temp\build7666495859859217241.tmp\Wire\utility\twi.c.o
C:\Program-Arduino\arduino-1.0.1\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -IC:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino -IC:\Program-Arduino\arduino-1.0.1\hardware\arduino\variants\mega -IC:\Program-Arduino\arduino-1.0.1\libraries\Wire -IC:\Program-Arduino\arduino-1.0.1\libraries\DS1307 -IC:\Program-Arduino\arduino-1.0.1\libraries\DS1307\utility C:\Program-Arduino\arduino-1.0.1\libraries\DS1307\DS1307.cpp -o C:\Users\Ric\AppData\Local\Temp\build7666495859859217241.tmp\DS1307\DS1307.cpp.o
In file included from C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:26,
from C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/Stream.h:26,
from C:\Program-Arduino\arduino-1.0.1\libraries\Wire/../Wire/Wire.h:26,
from C:\Program-Arduino\arduino-1.0.1\libraries\DS1307\DS1307.cpp:2:
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:116: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, const char*)' conflicts with
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:115: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const String&)' here
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:116: warning: 'StringSumHelper& operator+(const StringSumHelper&, const char*)' is already a friend of class 'String'
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:117: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, char)' conflicts with
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:116: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const char*)' here
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:117: warning: 'StringSumHelper& operator+(const StringSumHelper&, char)' is already a friend of class 'String'
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:118: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' conflicts with
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:117: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, char)' here
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:118: warning: 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' is already a friend of class 'String'
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:119: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, int)' conflicts with
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:118: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' here
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:119: warning: 'StringSumHelper& operator+(const StringSumHelper&, int)' is already a friend of class 'String'
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:120: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' conflicts with
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:119: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, int)' here
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:120: warning: 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' is already a friend of class 'String'
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:121: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, long int)' conflicts with
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:120: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' here
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:121: warning: 'StringSumHelper& operator+(const StringSumHelper&, long int)' is already a friend of class 'String'
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:122: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, long unsigned int)' conflicts with
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:121: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, long int)' here
C:\Program-Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/WString.h:122: warning: 'StringSumHelper& operator+(const StringSumHelper&, long unsigned int)' is already a friend of class 'String'
C:\Program-Arduino\arduino-1.0.1\libraries\DS1307\DS1307.cpp: In member function 'void DS1307::set(int, int)':
C:\Program-Arduino\arduino-1.0.1\libraries\DS1307\DS1307.cpp:97: warning: suggest parentheses around arithmetic in operand of |
The library files are from Google Code Archive - Long-term storage for Google Code Project Hosting.
Each has been modified to try and bring them up to compatibility with 1.0+ (this is something I am trying to do; accordingly I do not want to revert to 023).
The header code is attached.
#include <WConstants.h> has been changed to #include <Arduino.h>
The associated cpp file is also attached.
In the latterthere is no difference if I change the line:
#include <../Wire/Wire.h>
to
#include <Wire.h>
Other changes to the original cpp file (from the Google link) are to replace "Wire.send" with "Wire.write" and to replace "Wire.receive" with "Wire.read".
The sketch to test it all is attached:
The conflict appears to arise at lines 115 onwards in Wsring.h Yet I doubt this is the cause of the problem, more a symptom. Similarly the error highlighted in "void DS1307::set(int, int)" towards the end is probably not the issue either.
My two questions are: Can someone explain what is going wrong and why in this specific instance? Secondly. what is the general principle involving declarations within sketches where libraries themselves reference the same declarations and what approach would constitute good practice.
Thanks,
Ric
DS1307.ino (667 Bytes)
DS1307.h (1.33 KB)
DS1307.cpp (3.62 KB)