struct tm timeb

J

Jeff Kish

I'm using an old compiler.
Can someone tell me if there is a way to convert from a struct tm to a timeb?

Not sure how to go about it. It is a really old app I'm working with.
thanks
Jeff
Jeff Kish
 
M

Mike Wahler

Jeff Kish said:
I'm using an old compiler.
Can someone tell me if there is a way to convert from a struct tm to a
timeb?

Not sure how to go about it. It is a really old app I'm working with.
thanks

You'll need to check your compiler's documentation.
Standard C++ does not have a type 'timeb'.

-Mike
 
J

Jeff Kish

You'll need to check your compiler's documentation.
Standard C++ does not have a type 'timeb'.

-Mike
sigh. thanks. this is really old...
I think standard C does. Is this an area where C++ won't work with some C
calls?

Is there a recommended way to get from these sort of C time structures to C++?


Jeff Kish
 
V

Victor Bazarov

Jeff said:
sigh. thanks. this is really old...
I think standard C does. Is this an area where C++ won't work with
some C calls?

Standard C does *not* have 'timeb'.
Is there a recommended way to get from these sort of C time
structures to C++?

Post your code, post your requirements (or what the code used to do)
and we can help you figure it out.

Usually to get a C type into C++ you just drop the decoration (like
in your case 'struct tm' becomes 'tm').

V
 
L

Larry Smith

Jeff said:
I'm using an old compiler.
Can someone tell me if there is a way to convert from a struct tm to a timeb?

Not sure how to go about it. It is a really old app I'm working with.
thanks
Jeff
Jeff Kish

'timeb' was used by the old BSD ftime() function.
The same basic info can be obtained by creating
a 'tm' struct using ISO 9899 gmtime() or localtime().
For example:

#include <time.h>

struct tm * pTm;
struct tm tmNow;

pTm = localtime( time(0) );

/* if got the time, make a copy before another thread
* changes the global used by localtime().
* on unix, use the thread-safe localtime_r() instead.
*/
if (pTm)
tmNow = *pTm;
else
/* localtime() error */
 

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
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top