Compilation Errors

Hi,

I get the following compilation errors which do not relate to the files indicated.

In file included from MSFTimeSetter.cpp:17:
/home/ian/Arduino-1.0/libraries/RTClib/RTClib.h:17: error: expected unqualified-id before '/' token
/home/ian/Arduino-1.0/libraries/RTClib/RTClib.h:17: error: expected ')' before '/' token
/home/ian/Arduino-1.0/libraries/RTClib/RTClib.h:17: error: expected ')' before '/' token
/home/ian/Arduino-1.0/libraries/RTClib/RTClib.h:17: error: expected ')' before '/' token

I have found similar issues in the old forum, but the solutions offered do not appear to apply.

I am using Mandriva Linux and got the same issue in Arduino 0022

Thanks :~

Me again.

More info.

Previous successful sketches have used SD, Wire ,RTClib and LiquidCrystal in various combinations.
The one in question is using Wire, RTClib and MSFTime which includes wiring and Time .

Any help?

Open this file, and see what is at line 17. Post here and maybe I can help.
/home/ian/Arduino-1.0/libraries/RTClib/RTClib.h

First chunk of RTClib.h

// Released to the public domain! Enjoy!

// Simple general-purpose date/time class (no TZ / DST / leap second handling!)
class DateTime {
public:
DateTime (uint32_t t =0);
DateTime (uint16_t year, uint8_t month, uint8_t day,
uint8_t hour =0, uint8_t min =0, uint8_t sec =0);
DateTime (const char* date, const char* time);
uint16_t year() const { return 2000 + yOff; }
uint8_t month() const { return m; }
uint8_t day() const { return d; }
uint8_t hour() const { return hh; }
uint8_t minute() const { return mm; }
uint8_t second() const { return ss; }
uint8_t dayOfWeek() const;

// 32-bit times as seconds since 1/1/2000
long secondstime() const;
// 32-bit times as seconds since 1/1/1970
uint32_t unixtime(void) const;

I think this is your problem:

uint8_t dayOfWeek() const;

It needs to be something like this:

uint8_t dayOfWeek() const { return X; };

But I don't know what the day of week abbreviation is. I used 'X'.

Edit: I found this. I did not try it. Maybe it will work for you.

uint8_t DateTime::dayOfWeek() const { uint16_t day = date2days(yOff, m, d); return (day + 6) % 7; }

Tim
This code is C++ declaration code so you do not have to specify the implementation.
I copied this code in eclipse and eclipse says the code is fine.
To say anything useful we need more code.
Best regards
Jantje

Thanks Jante.

I was not aware we were dealing with Eclipse. This declaration throws an error in IDE V0022 and V1.0:
uint8_t dayOfWeek() const;

This doesn't:
uint8_t dayOfWeek();

This is normally the error generated when a define tries to replace a function declaration. The function declaration becomes invalid (malformed) after the define. Maybe in this case, is is malformed without the define?

In file included from MSFTimeSetter.cpp:17:
/home/ian/Arduino-1.0/libraries/RTClib/RTClib.h:17: error: expected unqualified-id before '/' token
/home/ian/Arduino-1.0/libraries/RTClib/RTClib.h:17: error: expected ')' before '/' token
/home/ian/Arduino-1.0/libraries/RTClib/RTClib.h:17: error: expected ')' before '/' token
/home/ian/Arduino-1.0/libraries/RTClib/RTClib.h:17: error: expected ')' before '/' token

Tim
I'm all puzzled now.
As the code was only a snippet I put it into eclipse to see what the compiler says. I never assumed the project was compiled in eclipse.
I have never seen any difference between my eclipse plugin and the arduino and there shouldn't be any as they use the same compiler and same compiler sequence and same compiler options (except for I specify explicit C++ compilation, but that is irrelevant here)
As you sure know, having const behind a function means you can not change the value of members in the function. Therefore it only involves code verification and no translation activities.
So I'm really surprised this throws an error in Arduino 22 and 1.0 (and not 23?).
The environment I used was using Arduino 23 so that does not invalidate your statement :slight_smile: nor mine :).

I just tried RTCLib from adafruit and it works fine in eclipse with Arduino 1.0.
I come to the same conclusion "To say anything useful we need more code."
Best regards
Jantje

Hi Jantje. This function declaration throws an error on V0022 and V1.0. It doesn't on yours?

uint8_t testFunct() const;

void setup() 
{
}

void loop() 
{
}

It generates this error:

sketch_jan21a.cpp:4:21 error: non-member function uint8_t testFunct() cannot have a cv qualifier

Remove the "const" and it compiles fine.

Am I missing something here?
Add: Actually, I missed something. That is a c++ "public" declaration, not a sketch. My bad.
This compiles ok:

class testme {
public:
uint8_t testFunct() const;
};

void setup()
{
  
}

void loop()
{
  
}

I guess you are correct. More is needed...

Tim
I checked your code snippet. You are right It gives a problem in 23 1.0 using the Arduino IDE and it gives a problem in eclipse using Arduino library 23 (and I assume 1.0 as well).
So it is consistent between Eclipse and Arduino 8).
So your input puzzled me (thanks for that). I needed some thought about it and now I understand why. It is a typical context problem. So everybody thinks he is right and the others are wrong but everybody makes sense in a different context.

The code snippet doesn't make sense to the compiler. (out of the context of a class)

uint8_t testFunct() const;

Const means your object will not change. As this method is not linked to an object it doesn't make sense.
If you place the snippet in the context of a class it makes perfect sense.

class tt {
public :
	uint8_t testFunct() const;
};

If you try this code snippet it works in Arduino ID E 23 1.0 and eclipse using 23 and 1.0.

Edders code was in the context of a class so his code is OK.
I can stick to my conclusion "To say anything useful we need more code."

best regards
Jantje

PS Note that the compiler used in Arduino is not known for his "comprehensive explanations" in case of errors.

Thanks. I see now. I tried that and it compiled ok.

Tim
Lol
Looks like we were typing the same thing at the same time :slight_smile:
Best regards
Jantje

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 did : 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 {