RTClib Library returning strange errors

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
wailingwalrus
 
Posts: 5
Joined: Sun Dec 04, 2011 4:19 pm

RTClib Library returning strange errors

Post by wailingwalrus »

Hi, I am working on this project that included the RTClib library to be used with the ds1307 rtc clock, but for some odds reason it started returning weird errors that the compiler said were being caused by RTClib.h, I followed the other post about this which fixed alot of the errors but still left about five left over. This is quite odd mostly because it had been compiled several times before without the compiler choking up but I couldn't figure out what the issue is. All of the errors say that an "unqualified id" or "}" was expected before the "/" token.

In file included from TrashCan.cpp:7:
C:\Users\Zinke Family\Downloads\Documents\KYLES STUFF\KYLES PROGRAMS\arduino-1.0-windows\arduino-1.0\libraries\RTClib/RTClib.h:17: error: expected unqualified-id before '/' token
C:\Users\Zinke Family\Downloads\Documents\KYLES STUFF\KYLES PROGRAMS\arduino-1.0-windows\arduino-1.0\libraries\RTClib/RTClib.h:17: error: expected `)' before '/' token
C:\Users\Zinke Family\Downloads\Documents\KYLES STUFF\KYLES PROGRAMS\arduino-1.0-windows\arduino-1.0\libraries\RTClib/RTClib.h:17: error: expected `)' before '/' token
C:\Users\Zinke Family\Downloads\Documents\KYLES STUFF\KYLES PROGRAMS\arduino-1.0-windows\arduino-1.0\libraries\RTClib/RTClib.h:17: error: expected `)' before '/' token


I have tried re downloading and replacing the header file, but to no avail.

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: RTClib Library returning strange errors

Post by adafruit_support_bill »

Post the code that has the problem.

wailingwalrus
 
Posts: 5
Joined: Sun Dec 04, 2011 4:19 pm

Re: RTClib Library returning strange errors

Post by wailingwalrus »

Code: Select all

  #include <Wire.h>
  #include <LiquidCrystal.h>
  #include <Time.h>
  #include <TimeAlarms.h>
  #include <Servo.h>
  #include <RTClib.h>
  RTC_DS1307 RTC;
  int timeh = 8;
  int timem = 30;
  boolean twice = false;
  
void setup() {
  // put your setup code here, to run once:
  
  Serial.begin(9600);
  lcd.begin(16, 2);
  RTC.adjust(DateTime(__DATE__, __TIME__));
  DateTime now = RTC.now();
  Alarm.alarmRepeat(timeh,timem,0,FeedTime);
}
void loop() {
  // put your main code here, to run repeatedly: 
  lcd.clear();
  
  lcd.print(now());
}
I got red of all of the code that wouldn't and shouldn't affect the affect the library not working like it says to do but all the libraries are still at the top.

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: RTClib Library returning strange errors

Post by adafruit_support_bill »

Looks like you are using Arduino 1.0. There are some incompatibilities between 1.0 and previous versions. I suspect one or more of your libraries have not been updated to 1.0.

wailingwalrus
 
Posts: 5
Joined: Sun Dec 04, 2011 4:19 pm

Re: RTClib Library returning strange errors

Post by wailingwalrus »

Yes I am, should I use the 022 version?

*edited
When I used the 022 it still didn't work

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: RTClib Library returning strange errors

Post by adafruit_support_bill »

Did you get the same error messages?

wailingwalrus
 
Posts: 5
Joined: Sun Dec 04, 2011 4:19 pm

Re: RTClib Library returning strange errors

Post by wailingwalrus »

Yes:
In file included from sketch_dec11a.cpp:7:
C:\Users\Zinke Family\Downloads\Documents\KYLES STUFF\KYLES PROGRAMS\arduino-0022\arduino-0022\libraries\RTClib/RTClib.h:17: error: expected unqualified-id before '/' token
C:\Users\Zinke Family\Downloads\Documents\KYLES STUFF\KYLES PROGRAMS\arduino-0022\arduino-0022\libraries\RTClib/RTClib.h:17: error: expected `)' before '/' token
C:\Users\Zinke Family\Downloads\Documents\KYLES STUFF\KYLES PROGRAMS\arduino-0022\arduino-0022\libraries\RTClib/RTClib.h:17: error: expected `)' before '/' token
C:\Users\Zinke Family\Downloads\Documents\KYLES STUFF\KYLES PROGRAMS\arduino-0022\arduino-0022\libraries\RTClib/RTClib.h:17: error: expected `)' before '/' token

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: RTClib Library returning strange errors

Post by adafruit_support_bill »

It could be a conflict with one of the other libraries. Try moving RTCLib to the top of the include list and see if the errors move or change.

wailingwalrus
 
Posts: 5
Joined: Sun Dec 04, 2011 4:19 pm

Re: RTClib Library returning strange errors

Post by wailingwalrus »

Doesn't work at top but I did get it working, you have to have it directly under wire.h and wire.h at the top. Thanks for you help!

f8eho
 
Posts: 1
Joined: Mon Mar 19, 2012 8:24 am

Re: RTClib Library returning strange errors

Post by f8eho »

Hello,

I found that in Time.h there is a #define that interact with a function in the DateTime class in RTClib.h

in RTClib.h line 17 there is :
uint8_t dayOfWeek() const ;

and in Time.h of the arduino Time library
#define dayOfWeek(_time_) ((( _time_ / SECS_PER_DAY + 4) % DAYS_PER_WEEK)+1) //

and this is why you have the error on line 17.

A solution could be to not use the time library or to modify one of the two libs.
Here is the way i do : I renamed the function dayOfWeek() to dayOfWeek2() in
RTClib.h line 17:
uint8_t dayOfWeek2() const ;
and in RTClib.cpp line 113:
uint8_t DateTime::dayOfWeek2() const {

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”