Library for time.h Functions - Windows CE

This is a discussion on Library for time.h Functions - Windows CE ; Which Library do I have to link to to get these Functions. At the same time I would like to know about the other Standard C functions. -- All the best, Isr Gish...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Library for time.h Functions

  1. Library for time.h Functions

    Which Library do I have to link to to get these Functions.

    At the same time I would like to know about the other Standard C functions.

    --
    All the best,
    Isr Gish


  2. Re: Library for time.h Functions

    Isr Gish wrote:

    > Which Library do I have to link to to get these Functions.


    time() is not included with WindowsCE.

    > At the same time I would like to know about the other Standard C functions.


    Most of the standard C functions are included without additional libraries, but
    as I said above some, like time() were omitted by Microsoft.

    I have posted this code before, but here it is again:

    -----------------------------------------------------------------------------
    Here is a modified code snippet from my free networking library, HawkNL. HawkNL
    supports portable routines across Windows 9x/ME/NT/2000/XP/CE, Linux and other
    Unixs, and MacOS. Replacements for ftime() and time() are included below.

    struct timeb {
    time_t time;
    unsigned short millitm;
    };

    static void ftime( struct timeb *tb )
    {
    SYSTEMTIME st;
    int days, years, leapyears;

    if(tb == NULL)
    {
    nlSetError(NL_NULL_POINTER);
    return;
    }
    GetSystemTime(&st);
    leapyears = (st.wYear - 1970 + 1) / 4;
    years = st.wYear - 1970 - leapyears;

    days = years * 365 + leapyears * 366;

    switch (st.wMonth) {
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
    days += 31;
    break;
    case 4:
    case 6:
    case 9:
    case 11:
    days += 30;
    break;
    case 2:
    days += (st.wYear%4 == 0) ? 29 : 28;
    break;
    default:
    break;
    }
    days += st.wDay;
    tb->time = days * 86400 + st.wHour * 3600 + st.wMinute * 60 + st.wSecond;
    tb->millitm = st.wMilliseconds;
    }

    time_t time(time_t *t)
    {
    struct timeb tb;

    ftime(&tb);
    *t = tb.time;

    return *t;
    }

    --
    Phil Frisbie, Jr.
    Hawk Software
    http://www.hawksoft.com


  3. Re: Library for time.h Functions

    Using Embedded Visual C++ 4.0 (eMVC), one can certainly #include
    , use time(), ctime(), time_t, etc. The code will _compile_
    okay. However, the _linker_ will generate error(s), e.g., "error
    LNK2019: unresolved external symbol _ctime".

    I used the /E compiler option to send the preprocessor output to stdout
    and did in fact see struct tm, ctime, etc. being included.

    Why, oh, why, didn't MS include the code for the linker?

    Do they not realize the extend of the non-Windows non-GUI based
    embedded applications in existence? My "standard C" code
    compiles/links under GNU (gcc) and three different versions of Borland
    C. But nooo, eMVC won't compile (and/or) link it! That's ridiculous!


  4. Re: Library for time.h Functions

    Jimbo wrote:

    > Using Embedded Visual C++ 4.0 (eMVC), one can certainly #include
    > , use time(), ctime(), time_t, etc. The code will _compile_
    > okay. However, the _linker_ will generate error(s), e.g., "error
    > LNK2019: unresolved external symbol _ctime".


    On eMVC 3.0 time() is not even prototyped!

    > I used the /E compiler option to send the preprocessor output to stdout
    > and did in fact see struct tm, ctime, etc. being included.


    Yes, the structures are defined, but they are not much use without the functions.

    > Why, oh, why, didn't MS include the code for the linker?


    Microsoft has never answered that one.....

    > Do they not realize the extend of the non-Windows non-GUI based
    > embedded applications in existence? My "standard C" code
    > compiles/links under GNU (gcc) and three different versions of Borland
    > C. But nooo, eMVC won't compile (and/or) link it! That's ridiculous!


    Yes, that is why I created my own ftime() and time() so that I could port code.

    --
    Phil Frisbie, Jr.
    Hawk Software
    http://www.hawksoft.com

  5. Re: Library for time.h Functions

    "Phil Frisbie, Jr." wrote:

    >> Which Library do I have to link to to get these Functions.

    >time() is not included with WindowsCE.


    hmm, this is only half the truth.
    time() is prototyped in eVC++4 SP 2 (may be lower versions too)

    if one compiles *.c with time(), you are right. the linker fails to
    bind code to that

    if one compiles *.cpp, the linker can find a class time() that was
    made completely identical in the interfacing, so a C++ programmer will
    never find out, that the msvcrt.dll lacks of Ansi-C-time().


    Mai Kee

    --
    Hamster beisst sich durch ...

+ Reply to Thread