Include time.h function

Discussion in 'C' started by cky1123, Mar 6, 2007.

  1. cky1123

    cky1123 New Member

    Joined:
    Jan 17, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Hi all,

    I'm trying to use the C function time() in my program but it keeps complaining "called object is not a function" but I've already included the header file. #include <sys/time.h>
    Does this mean it doesn't find the header file and so it does not recognize the function? thanx in advance.

    Catherine
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    Most compilers would give you a "file not found" type of error if an include file is not found. Whether or not the file is in sys or not depends upon the compiler. Have you checked for the presence of the file?

    Header files do not include the actual functions. They merely declare their form. The library that contains the actual code must be present and be able to be found during the linker phase. This is unlikely to be the problem with something like time, though.

    You should always give information about your system, OS, and compiler; particularly for stranger behavior regarding system library code. Perhaps you could also show a snippet of the code where the error occurs, in case of syntax errors at or shortly before the point where the error is flagged.
     
  3. cky1123

    cky1123 New Member

    Joined:
    Jan 17, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    ops.. i figured it out. I actually had another variable name int time which was causing the problem. Thanx ..
     
  4. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    Ahhh, the beauty of C++ and namespaces :D.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice