This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

uvision: time.h undefined time symbol

hi,

could someone tell me the way to work with the time.h header file? At the moment I get the error message "undefined symbol time"

#include <stdio.h>
#include <time.h>
#include "math.h"

//....

//line which generates the error message:
time_t t = time(NULL);

I'm no sure which header file is missing... Or if there's any other error... by the way I'm working with the AT91SAM9260 controller...

best regards
Stefan

Parents
  • Alternatively, you could say that header files tell the compiler to assume that the symbol exists (with the type stated), and generate code accordingly. Thus compilation can proceed, but the Linker needs to see the real thing.

    Another way of putting it is that, in the header file, you make a promise to the compiler that you will provide the stated symbols; it is only the Linker that calls you to fulfil your promise

Reply
  • Alternatively, you could say that header files tell the compiler to assume that the symbol exists (with the type stated), and generate code accordingly. Thus compilation can proceed, but the Linker needs to see the real thing.

    Another way of putting it is that, in the header file, you make a promise to the compiler that you will provide the stated symbols; it is only the Linker that calls you to fulfil your promise

Children
  • thank you for your really good answers.

    The bad thing here, is I that can't figure out if you can replace any underlying functions if you need to use time(), or if you should replace the function with your own...

    A few things about the project.

    I'm working with the DS1337 RTC connected via I2C. At startup I have to configurate the RTC with the right time (year, day, hours, seconds and so on). I need the RTC for the ethernet stack. But it's very seldom that the fixture has access to the internet. Moreover the fixture is not always switched on.

    So I think I should also be possible to use the localtime() function.

    At the moment I'm not sure how do I get the right time?

    best regards
    Stefan

  • 1) What do you mean by "I need the RTC for the ethernet stack"? Why would your etnernet stack need to know the exact time of day or what date it is?

    2) "At the moment I'm not sure how do I get the right time?" If your unit do need absolute time, then it is up to you to figure out where/how to get the initial time into your RTC. With ethernet support, you may possibly use an SNTP implementation - a quite simple way of requesting time using UDP.

  • 1) I also want to install the protocoll snmp.

    2) SNTP - I will take a look over this protocoll. If it is possible to get a right time from another computer in the local-net then it will solve my problem...and everything would be right.

    thanks for the hint

    best regards
    Stefan