Connecting Tech Pros Worldwide Forums | Help | Site Map

Return value of _time64()

babak
Guest
 
Posts: n/a
#1: Jan 2 '06
Hi
I have a rather simple question that I haven't succeded to find the
answer for in MSDN or other help pages.
I'm using _time64() in VS2005 and I need to know what the return value
of that function is. More precisely, which of the following is correct:

1. DWORD temp = _time64(0);
2. DWORD temp = (_time64(0) >> 32);
or
3. DWORD temp = (DWORD)_time64(0);

where DWORD is an unsigned long (32 bits).

Thanks for your help.

Regards.
/Babak


Jack Klein
Guest
 
Posts: n/a
#2: Jan 2 '06

re: Return value of _time64()


On 2 Jan 2006 02:00:44 -0800, "babak" <babak.ayani@gmail.com> wrote in
comp.lang.c++:
[color=blue]
> Hi
> I have a rather simple question that I haven't succeded to find the
> answer for in MSDN or other help pages.
> I'm using _time64() in VS2005 and I need to know what the return value
> of that function is. More precisely, which of the following is correct:
>
> 1. DWORD temp = _time64(0);
> 2. DWORD temp = (_time64(0) >> 32);
> or
> 3. DWORD temp = (DWORD)_time64(0);
>
> where DWORD is an unsigned long (32 bits).
>
> Thanks for your help.
>
> Regards.
> /Babak[/color]

The _time64() function is not part of the C++ language, it is a
non-standard, Windows specific extension, so it's off-topic here and
you should be asking about it in a Windows programming group.

But these pages seem to make it pretty clear:

http://msdn.microsoft.com/library/de.../_crt_time.asp
http://msdn.microsoft.com/library/de...dard_Types.asp

By the way, if you only want 32 bits of time resolution, you are
calling the wrong function. Instead of calling a 64 bit function and
throwing away half the result, you could call the standard time()
function instead.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
babak
Guest
 
Posts: n/a
#3: Jan 2 '06

re: Return value of _time64()


Jack,
time() does not work in VS2005 (or at least not in my environment).
Otherwise I would ofcourse have used it.
I will sent my question to a windows group and hope for better luck
there.

/Babak

Jack Klein skrev:
[color=blue]
> On 2 Jan 2006 02:00:44 -0800, "babak" <babak.ayani@gmail.com> wrote in
> comp.lang.c++:
>[color=green]
> > Hi
> > I have a rather simple question that I haven't succeded to find the
> > answer for in MSDN or other help pages.
> > I'm using _time64() in VS2005 and I need to know what the return value
> > of that function is. More precisely, which of the following is correct:
> >
> > 1. DWORD temp = _time64(0);
> > 2. DWORD temp = (_time64(0) >> 32);
> > or
> > 3. DWORD temp = (DWORD)_time64(0);
> >
> > where DWORD is an unsigned long (32 bits).
> >
> > Thanks for your help.
> >
> > Regards.
> > /Babak[/color]
>
> The _time64() function is not part of the C++ language, it is a
> non-standard, Windows specific extension, so it's off-topic here and
> you should be asking about it in a Windows programming group.
>
> But these pages seem to make it pretty clear:
>
> http://msdn.microsoft.com/library/de.../_crt_time.asp
> http://msdn.microsoft.com/library/de...dard_Types.asp
>
> By the way, if you only want 32 bits of time resolution, you are
> calling the wrong function. Instead of calling a 64 bit function and
> throwing away half the result, you could call the standard time()
> function instead.
>
> --
> Jack Klein
> Home: http://JK-Technology.Com
> FAQs for
> comp.lang.c http://c-faq.com/
> comp.lang.c++ http://www.parashift.com/c++-faq-lite/
> alt.comp.lang.learn.c-c++
> http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html[/color]

Jack Klein
Guest
 
Posts: n/a
#4: Jan 2 '06

re: Return value of _time64()


On 2 Jan 2006 02:39:23 -0800, "babak" <babak.ayani@gmail.com> wrote in
comp.lang.c++:
[color=blue]
> Jack,
> time() does not work in VS2005 (or at least not in my environment).
> Otherwise I would ofcourse have used it.[/color]

Surely you are doing something wrong. time() works on every
conforming C and C++ implementation in existence.

I just built and ran this console application on VS2005 beta 2 (I
haven't gotten around to removing it and installing the release
version):

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

int main(void)
{
time_t time1 = time(NULL);
struct tm time2 = *localtime(&time1);
printf("%s\n", asctime(&time2));
return 0;
}

And here is the output in the console window:

Mon Jan 02 15:03:18 2006
Press any key to continue . . .

So if time() does not work for you, there is something wrong with your
installation or your program.
[color=blue]
> I will sent my question to a windows group and hope for better luck
> there.
>
> /Babak
>
> Jack Klein skrev:
>[color=green]
> > On 2 Jan 2006 02:00:44 -0800, "babak" <babak.ayani@gmail.com> wrote in
> > comp.lang.c++:
> >[color=darkred]
> > > Hi
> > > I have a rather simple question that I haven't succeded to find the
> > > answer for in MSDN or other help pages.
> > > I'm using _time64() in VS2005 and I need to know what the return value
> > > of that function is. More precisely, which of the following is correct:
> > >
> > > 1. DWORD temp = _time64(0);
> > > 2. DWORD temp = (_time64(0) >> 32);
> > > or
> > > 3. DWORD temp = (DWORD)_time64(0);
> > >
> > > where DWORD is an unsigned long (32 bits).
> > >
> > > Thanks for your help.
> > >
> > > Regards.
> > > /Babak[/color]
> >
> > The _time64() function is not part of the C++ language, it is a
> > non-standard, Windows specific extension, so it's off-topic here and
> > you should be asking about it in a Windows programming group.
> >
> > But these pages seem to make it pretty clear:
> >
> > http://msdn.microsoft.com/library/de.../_crt_time.asp
> > http://msdn.microsoft.com/library/de...dard_Types.asp
> >
> > By the way, if you only want 32 bits of time resolution, you are
> > calling the wrong function. Instead of calling a 64 bit function and
> > throwing away half the result, you could call the standard time()
> > function instead.[/color][/color]

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
BobR
Guest
 
Posts: n/a
#5: Jan 2 '06

re: Return value of _time64()



babak wrote in message
<1136198363.229281.164050@g44g2000cwa.googlegroups .com>...[color=blue]
>Jack,
>time() does not work in VS2005[/color]

Did you bother to :

#include <ctime>


Do NOT top-post, and trim everything you are not replying to.
comp.lang.c++ http://www.parashift.com/c++-faq-lite/

--
Bob R
POVrookie


John Smith
Guest
 
Posts: n/a
#6: Jan 5 '06

re: Return value of _time64()


>[color=blue]
> Surely you are doing something wrong. time() works on every
> conforming C and C++ implementation in existence.
>[/color]

Just to follow up on this you must notice that standard time_t in VS 2005 is
64 bit and thus will call the 64 bit time(). If you want to use the "normal"
32 bit you must define the macro _USE_32BIT_TIME_T. Prior versions of VS
only had 32 bit time.

-- John


Closed Thread