1 2 Previous Next 19 Replies Latest reply on Jan 5, 2015 2:54 PM by Intel_Alvarado

    Compile error with the time function

    AlphaCHarly

      A program that compiles Ok under Arduino Galileo 1.5.3 it gives the following error under Arduino Edison 1.5.3 1.0.4

      ----

      Arduino: 1.5.3-Intel.1.0.4 (Mac OS X), Board: "Intel® Edison"

       

       

      In file included from /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/sys/stat.h:105:0,

                       from /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/arduino/edison/libraries/SPI/SPI.cpp:13:

      /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/bits/stat.h:91:21: error: field 'st_atim' has incomplete type

           struct timespec st_atim;  /* Time of last access.  */

                           ^

      /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/bits/stat.h:92:21: error: field 'st_mtim' has incomplete type

           struct timespec st_mtim;  /* Time of last modification.  */

                           ^

      /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/bits/stat.h:93:21: error: field 'st_ctim' has incomplete type

           struct timespec st_ctim;  /* Time of last status change.  */

                           ^

      /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/bits/stat.h:152:21: error: field 'st_atim' has incomplete type

           struct timespec st_atim;  /* Time of last access.  */

                           ^

      /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/bits/stat.h:153:21: error: field 'st_mtim' has incomplete type

           struct timespec st_mtim;  /* Time of last modification.  */

                           ^

      /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/bits/stat.h:154:21: error: field 'st_ctim' has incomplete type

           struct timespec st_ctim;  /* Time of last status change.  */

                           ^

       

       

        This report would have more information with

        "Show verbose output during compilation"

        enabled in File > Preferences.

      ----

      A deeper inspection tells me that is something related to the timespec struct not being defined in the right place.

      Anyone found a similar problem ???

      Thx.

      AC/.

        • 1. Re: Compile error with the time function
          Intel_Alvarado

          Hi AlphaCHarly,

          Could you please attach the complete code you used that gave you this error?

          Regards

          Sergio

          • 2. Re: Compile error with the time function
            AlphaCHarly

            Sergio:

             

            Here it goes very basic indeed .... just the empty skeleton ... and you get the error ... I downloaded the IDE before yesterday ...

             

            #include <Arduino.h>

            #include <sys/types.h>

            #include <sys/stat.h>

            #include <Time.h>

            #include <sys/time.h>

            void setup() {

              // put your setup code here, to run once:

            }

            void loop() {

              // put your main code here, to run repeatedly:

            }

            -----

            Arduino: 1.5.3-Intel.1.0.4 (Mac OS X), Board: "Intel® Edison"

             

             

            In file included from /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/sys/stat.h:105:0,

                             from sketch_nov01a.ino:3:

            /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/bits/stat.h:91:21: error: field 'st_atim' has incomplete type

                 struct timespec st_atim;  /* Time of last access.  */

                                 ^

            /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/bits/stat.h:92:21: error: field 'st_mtim' has incomplete type

                 struct timespec st_mtim;  /* Time of last modification.  */

                                 ^

            /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/bits/stat.h:93:21: error: field 'st_ctim' has incomplete type

                 struct timespec st_ctim;  /* Time of last status change.  */

                                 ^

            /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/bits/stat.h:152:21: error: field 'st_atim' has incomplete type

                 struct timespec st_atim;  /* Time of last access.  */

                                 ^

            /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/bits/stat.h:153:21: error: field 'st_mtim' has incomplete type

                 struct timespec st_mtim;  /* Time of last modification.  */

                                 ^

            /Users/acasado/Desktop/ArduinoEdison.app/Contents/Resources/Java/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/bits/stat.h:154:21: error: field 'st_ctim' has incomplete type

                 struct timespec st_ctim;  /* Time of last status change.  */

                                 ^

             

             

              This report would have more information with

              "Show verbose output during compilation"

              enabled in File > Preferences.

            • 3. Re: Compile error with the time function
              Intel_Alvarado

              Hi AlphaCHarly,

              That seems like a strange error. I just tried that code on my board and it did not showed any errors. I’d recommend you to follow the steps in this guide https://communities.intel.com/docs/DOC-23148 . According to your description you are using a MAC so give this guide a try and let us know your results.

              Regards

              Sergio

              • 4. Re: Compile error with the time function
                AlphaCHarly

                Sergio,

                I am really confuse ....

                With this code:

                ------

                #include <Arduino.h>

                #include <sys/types.h>

                #include <sys/stat.h>

                #include <Time.h>

                #include <sys/time.h>

                void setup() {

                  // put your setup code here, to run once:

                }

                void loop() {

                  // put your main code here, to run repeatedly:

                }

                ------

                I get the above error

                if I change <Time.h> with <time.h> I get no errors,

                however if I have the following also minimum skeleton, just commenting out include <sys/stat.h>

                 

                ------

                 

                #include <Arduino.h>

                #include <sys/types.h>

                // #include <sys/stat.h>

                #include <Time.h>

                #include <sys/time.h>

                void setup() {

                  // put your setup code here, to run once:

                }

                void loop() {

                  // put your main code here, to run repeatedly:

                }

                 

                I get no errors. So it is a problem of including <sys/stat.h>

                I wonder what is the problem ????

                I included the Time.h file as a reference.

                I saw a similar comment in another post.

                This program compiles Ok with the previous Galileo only IDE, it happens with the Galileo/Edison Arduino 1-5-3 Intel 1.0.4

                Thanks for your help Sergio.

                 

                AC/.

                --------------------------------------------------------------------------------

                /*

                time.h - low level time and date functions

                */

                 

                 

                /*

                  July 3 2011 - fixed elapsedSecsThisWeek macro (thanks Vincent Valdy for this)

                              - fixed  daysToTime_t macro (thanks maniacbug)

                */    

                 

                 

                #ifndef _Time_h

                #ifdef __cplusplus

                #define _Time_h

                 

                 

                #include <inttypes.h>

                #ifndef __AVR__

                #include <sys/types.h> // for __time_t_defined, but avr libc lacks sys/types.h

                #endif

                 

                 

                 

                 

                #if !defined(__time_t_defined) // avoid conflict with newlib or other posix libc

                typedef unsigned long time_t;

                #endif

                 

                 

                 

                 

                // This ugly hack allows us to define C++ overloaded functions, when included

                // from within an extern "C", as newlib's sys/stat.h does.  Actually it is

                // intended to include "time.h" from the C library (on ARM, but AVR does not

                // have that file at all).  On Mac and Windows, the compiler will find this

                // "Time.h" instead of the C library "time.h", so we may cause other weird

                // and unpredictable effects by conflicting with the C library header "time.h",

                // but at least this hack lets us define C++ functions as intended.  Hopefully

                // nothing too terrible will result from overriding the C library header?!

                extern "C++" {

                typedef enum {timeNotSet, timeNeedsSync, timeSet

                }  timeStatus_t ;

                 

                 

                typedef enum {

                    dowInvalid, dowSunday, dowMonday, dowTuesday, dowWednesday, dowThursday, dowFriday, dowSaturday

                } timeDayOfWeek_t;

                 

                 

                typedef enum {

                    tmSecond, tmMinute, tmHour, tmWday, tmDay,tmMonth, tmYear, tmNbrFields

                } tmByteFields;  

                 

                 

                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;

                 

                 

                //convenience macros to convert to and from tm years

                #define  tmYearToCalendar(Y) ((Y) + 1970)  // full four digit year

                #define  CalendarYrToTm(Y)   ((Y) - 1970)

                #define  tmYearToY2k(Y)      ((Y) - 30)    // offset is from 2000

                #define  y2kYearToTm(Y)      ((Y) + 30)  

                 

                 

                typedef time_t(*getExternalTime)();

                //typedef void  (*setExternalTime)(const time_t); // not used in this version

                 

                 

                 

                 

                /*==============================================================================*/

                /* Useful Constants */

                #define SECS_PER_MIN  (60UL)

                #define SECS_PER_HOUR (3600UL)

                #define SECS_PER_DAY  (SECS_PER_HOUR * 24UL)

                #define DAYS_PER_WEEK (7UL)

                #define SECS_PER_WEEK (SECS_PER_DAY * DAYS_PER_WEEK)

                #define SECS_PER_YEAR (SECS_PER_WEEK * 52UL)

                #define SECS_YR_2000  (946684800UL) // the time at the start of y2k

                 

                /* Useful Macros for getting elapsed time */

                #define numberOfSeconds(_time_) (_time_ % SECS_PER_MIN) 

                #define numberOfMinutes(_time_) ((_time_ / SECS_PER_MIN) % SECS_PER_MIN)

                #define numberOfHours(_time_) (( _time_% SECS_PER_DAY) / SECS_PER_HOUR)

                #define dayOfWeek(_time_)  ((( _time_ / SECS_PER_DAY + 4)  % DAYS_PER_WEEK)+1) // 1 = Sunday

                #define elapsedDays(_time_) ( _time_ / SECS_PER_DAY)  // this is number of days since Jan 1 1970

                #define elapsedSecsToday(_time_)  (_time_ % SECS_PER_DAY)   // the number of seconds since last midnight

                // The following macros are used in calculating alarms and assume the clock is set to a date later than Jan 1 1971

                // Always set the correct time before settting alarms

                #define previousMidnight(_time_) (( _time_ / SECS_PER_DAY) * SECS_PER_DAY)  // time at the start of the given day

                #define nextMidnight(_time_) ( previousMidnight(_time_)  + SECS_PER_DAY )   // time at the end of the given day

                #define elapsedSecsThisWeek(_time_)  (elapsedSecsToday(_time_) +  ((dayOfWeek(_time_)-1) * SECS_PER_DAY) )   // note that week starts on day 1

                #define previousSunday(_time_)  (_time_ - elapsedSecsThisWeek(_time_))      // time at the start of the week for the given time

                #define nextSunday(_time_) ( previousSunday(_time_)+SECS_PER_WEEK)          // time at the end of the week for the given time

                 

                 

                 

                 

                /* Useful Macros for converting elapsed time to a time_t */

                #define minutesToTime_t ((M)) ( (M) * SECS_PER_MIN) 

                #define hoursToTime_t   ((H)) ( (H) * SECS_PER_HOUR) 

                #define daysToTime_t    ((D)) ( (D) * SECS_PER_DAY) // fixed on Jul 22 2011

                #define weeksToTime_t   ((W)) ( (W) * SECS_PER_WEEK)  

                 

                 

                /*============================================================================*/

                /*  time and date functions   */

                int     hour();            // the hour now

                int     hour(time_t t);    // the hour for the given time

                int     hourFormat12();    // the hour now in 12 hour format

                int     hourFormat12(time_t t); // the hour for the given time in 12 hour format

                uint8_t isAM();            // returns true if time now is AM

                uint8_t isAM(time_t t);    // returns true the given time is AM

                uint8_t isPM();            // returns true if time now is PM

                uint8_t isPM(time_t t);    // returns true the given time is PM

                int     minute();          // the minute now

                int     minute(time_t t);  // the minute for the given time

                int     second();          // the second now

                int     second(time_t t);  // the second for the given time

                int     day();             // the day now

                int     day(time_t t);     // the day for the given time

                int     weekday();         // the weekday now (Sunday is day 1)

                int     weekday(time_t t); // the weekday for the given time

                int     month();           // the month now  (Jan is month 1)

                int     month(time_t t);   // the month for the given time

                int     year();            // the full four digit year: (2009, 2010 etc)

                int     year(time_t t);    // the year for the given time

                 

                 

                time_t now();              // return the current time as seconds since Jan 1 1970

                void    setTime(time_t t);

                void    setTime(int hr,int min,int sec,int day, int month, int yr);

                void    adjustTime(long adjustment);

                 

                 

                /* date strings */

                #define dt_MAX_STRING_LEN 9 // length of longest date string (excluding terminating null)

                char* monthStr(uint8_t month);

                char* dayStr(uint8_t day);

                char* monthShortStr(uint8_t month);

                char* dayShortStr(uint8_t day);

                 

                /* time sync functions */

                timeStatus_t timeStatus(); // indicates if time has been set and recently synchronized

                void    setSyncProvider( getExternalTime getTimeFunction); // identify the external time provider

                void    setSyncInterval(time_t interval); // set the number of seconds between re-sync

                 

                 

                /* low level functions to convert to and from system time                     */

                void breakTime(time_t time, tmElements_t &tm);  // break time_t into elements

                time_t makeTime(tmElements_t &tm);  // convert time elements into time_t

                 

                 

                } // extern "C++"

                #endif // __cplusplus

                #endif /* _Time_h */

                • 5. Re: Compile error with the time function
                  UST_

                  Hi AlphaCHarly ,

                   

                  I'm trying to use the Time and DS1307 provided on Arduino's playground, but I believe both of these are not meshing well with the Edison or maybe the new IDE.

                   

                  Over the next couple days I was going to try and play around with these libraries and compare them to RTClib ( https://github.com/jcw/rtclib ) which does work and provide the current time if you have a DS1307 hooked up to the Arduino-Edison breakout board.

                   

                  My question to you is if this Time.h file you posted is updated and new for the Arduino-Edison IDE, and if so can you link to where the whole library is located?

                   

                  Any insight would be appreciated.

                   

                  Cheers,

                   

                  UST

                  • 6. Re: Compile error with the time function
                    Terrence_

                    Alpha, I am having the same compile error.

                    • 7. Re: Compile error with the time function
                      KurtE

                      could it be you are on a linux processor where file names are case sensitive? So it does not find Time.h

                      .

                      • 8. Re: Compile error with the time function
                        AlphaCHarly

                        UST,

                        No it is the same Time.h that yu can find on the Arduino contributed libraries

                        Arduino Playground - Time

                        I solve my problem using the gettimeofday() function instead of the NTP function that uses SPI where I believe that is the causing error.

                        Still digging for what is the cause of the error.

                        AC/.

                        • 9. Re: Compile error with the time function
                          UST_

                          Hi AlphaCHarly,

                           

                          I'll keep an eye on your thread. The Time.h file I use from the Arduino Playground - Time causes a distinct error where the IDE thinks I'm making multiple declarations, which I guess technically the old Time.h does (but really it just makes a deceleration of the function then another one for current time).

                           

                          Where your Time.h file posted here fixes my issue but it kills my DS1307 library cause now Time.h file is all screwy; if I find something I'll post on my threads and here as well, and I'll keep an eye here.

                           

                          Cheers,

                           

                          UST

                          • 10. Re: Compile error with the time function
                            KurtE

                            Again not sure if this helps.  But I downloaded the Time library as mentioned and got the same compile errors.  I then commented out the line:

                            //#include <sys/stat.h>

                            in the ino file and it now compiles...  Not sure if it works, but.

                            1 of 1 people found this helpful
                            • 11. Re: Compile error with the time function
                              UST_

                              Hi KurtE,

                               

                              I apologize I am new to this so when you say .ino file I don't know what you are referring to. This why I am thinking I might have a different Time library.

                               

                              In my Time library I only have the "Time.h" , "Time.cpp" and "DateStrings.cpp" and all the .pde example files included with the library; but no where do I see any .ino files or any files (.cpp, .h, or .pde) that have #include<sys/stat.h> or any of the other includes from yours and AC's posts.

                               

                              I have never seen those includes which is why I was thinking I had an outdated Time library, but AC is saying he got his from the Arduino Playground - Time  which is exactly where I got mine, so I am very confused 

                               

                              Could be that since he's using a MAC it is different?

                               

                              Cheers,

                               

                              UST

                              • 12. Re: Compile error with the time function
                                KurtE

                                Sorry I was simply going by the program in posting #2 of this thread.

                                • 13. Re: Compile error with the time function
                                  UST_

                                  Gotcha - I tried even just adding those #includes for kicks and it just added a ton more errors

                                   

                                  But I'm confused with your guys issue, when I use the new Time.h file that was posted in #4 (which differs from mine even though we downloaded from the same source! where did he get it?!) it fixes my initial compile issue but then the sketch doesn't run properly cause I have  another library that is dependent on my old Time.h

                                   

                                  Cheers,

                                   

                                  UST

                                  • 14. Re: Compile error with the time function
                                    AlphaCHarly

                                    I did exactly the same as mentioned above ... Still I do not understand why ...

                                    1 2 Previous Next