Return value of _time64()

B

babak

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
 
J

Jack Klein

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

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/default.asp?url=/library/en-us/vclib/html/_crt_time.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_CRT_Standard_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.
 
B

babak

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:
 
J

Jack Klein

Jack,
time() does not work in VS2005 (or at least not in my environment).
Otherwise I would ofcourse have used it.

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.
 
J

John Smith

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top