Hi guys!
I am a n00b with arduino, never programmed C++, but I've been C programming for a while. 8)
My project is to make my arduino alarm clock, so that I get to learn the basics of arduino, and I will have the BEST alarm clock in the world!! (and I don't have to buy a new stupid one ).
So here's the fact: I am using arduino Time library, got through README and Time.h and found:
typedef struct {
 uint8_t Second;
 uint8_t Minute;
 uint8_t Hour;
 uint8_t Wday; // day of week, sunday is day 1
 uint8_t Day;
 uint8_t Month;
 uint8_t Year; // offset from 1970;
} tmElements_t, TimeElements, *tmElementsPtr_t;
/* ... */
void breakTime(time_t time, tmElements_t &tm);Â // break time_t into elements
So I used them:
#include <Time.h>
/* ... */
tmElements_t alarm = { 0, 0, 0, 0, 0, 0, 0 };
/* ... */
void setup() {
 /* ... */
 // sets default alarm time & date
 breakTime(305712000, &alarm);
 // unix time 305712000 is Sept 9 1979, 8:00 -- MY BDAY!
}
But,
when I tried compiling, I got this error:
TestAlarmClock.cpp: In function ‘void setup()’:
TestAlarmClock:211: error: invalid initialization of non-const reference of type ‘tmElements_t&’ from a temporary of type ‘tmElements_t*’
/usr/share/arduino/libraries/Time/Time.h:111: error: in passing argument 2 of ‘void breakTime(time_t, tmElements_t&)
I double checked definitions and declarations, and, as I though there was no error, I retried!
Still same error. I read compiling error more carefully, and removed trailing & on second argument. OK !
But, as I can't stand not understanding what goes on, specially in programming ]:), I posted this.
So... What is this "magic cast" that turns a struct variable into a pointer?
What am I missing? Is it C++ related? As far as I know, writing a correct C code will work in a C++ source...
Is it a correct C source??