Go Down

Topic: Compilation Errors (Read 4134 times) previous topic - next topic

edders

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     :~

edders

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?


SurferTim

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

edders

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;

SurferTim

#4
Jan 18, 2012, 06:33 pm Last Edit: Jan 18, 2012, 07:08 pm by SurferTim Reason: 1
I think this is your problem:
Code: [Select]
uint8_t dayOfWeek() const;
It needs to be something like this:
Code: [Select]
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.
Code: [Select]
uint8_t DateTime::dayOfWeek() const { uint16_t day = date2days(yOff, m, d); return (day + 6) % 7; }

Jantje

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
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

SurferTim

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?
Quote
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


Jantje

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  :) 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
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

SurferTim

#8
Jan 21, 2012, 01:00 pm Last Edit: Jan 21, 2012, 01:25 pm by SurferTim Reason: 1
Hi Jantje. This function declaration throws an error on V0022 and V1.0. It doesn't on yours?
Code: [Select]
uint8_t testFunct() const;

void setup()
{
}

void loop()
{
}


It generates this error:
Quote
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:
Code: [Select]
class testme {
public:
uint8_t testFunct() const;
};

void setup()
{
 
}

void loop()
{
 
}


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

Jantje

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)
Code: [Select]
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.
Code: [Select]
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.
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

SurferTim

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


Jantje

Tim
Lol
Looks like we were typing the same thing at the same time  :)
Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

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 :
Code: [Select]
uint8_t dayOfWeek() const ;and in Time.h of the arduino Time library
Code: [Select]
#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:
Code: [Select]
uint8_t dayOfWeek2() const ;and in RTClib.cpp line 113:
Code: [Select]
uint8_t DateTime::dayOfWeek2() const {

Go Up