I recently ported the Time library for Teensy 3.0. This doesn't directly support the Due RTC, but it's meant to work together with the library mentioned above.
Michael Margolis (author of this Time library) and I talked about the time_t compatibility issue. His preference was to rename it to atime_t. Probably "a" for Arduino?
Yuck! That seems like a dreadful solution.
Please, please don't go down that route. That is such a Windows-fix-of-the-moment type of fix.
That really breaks compatibility especially for those writing code that will use the time type for
things like calculating time intervals.
Why not use the
__time_t_defined define to determine whether or not the system has already typed time_t ?
The define could be tested to see if time_t needs to be typed in the library Time.h file.
This seems like a proper fix.
Add this to the Time library Time.h header file:
#ifndef __time_t_defined
typedef unsigned long time_t;
#endif
Then the STUPID IDE also has an issue that rears it ugly head again that breaks this.
The IDE inserts its prologue which includes
#include "Arduino.h"
in the middle of the sketch .cpp file so it ends up after the
#include <Time.h>
So the system version of time_t doesn't get typed before the library Time.h looks at the define.
You have to insert some dummy code to coerce the silly IDE to put the prologue at the top of the .cpp file
I added this to the example sketch:
int dummy = 0;
right at the top of the sketch.
(Can't the IDE be fixed to avoid this silly wrong location prologue insertion????)
One thing that is concerning to me is that since Windows is doesn't handle mixed case
on its file names, #include <Time.h> might end up pulling in the system time.h since it is earlier on the include path
(I don't do Windows so I'm not sure about that).
--- bill